n = int(input())
a = list(map(int, input().split()))

r = sum(a) // 3
print(0)
i = 0
while i < n:
    # print("i",i)
    j = i + 1
    if i == 0:
        maxj = n - 2
        maxk=n-1
    elif i == 1:
        maxj = n - 1
        maxk=n
    elif i == 2:
        maxj = n
        maxk=1
    else:
        maxj = i - 2
        maxk=i-1
    while j != maxj:

        if j > n:
            j = 0
        # print("j", j)

        if sum(a[i:j]) == r:
            # print(a[i:j])
            k = j + 1
            while k != maxk:

                if k > n:
                    k = 0
                # print("k", k)

                if sum(a[j:k]) == r:
                    print(i + 1, j + 1, k + 1)
                    exit()
                k += 1
        j += 1
    i += 1