n = int(input())
a = list(map(int, input().split()))
s = sum(a)
if s % 3 == 2:
    tru = s//3+1
    vid=1
else:
    vid=0
    if s % 3 == 1:
        vid=1
    tru = s // 3
q = a[0]
#print(s)
l = 0
r = 0
while q != tru:
    if q < tru:
        r += 1
        q += a[r]

    if q > tru:
        q -= a[l]
        l+=1
        if l>r:
            r += 1
            q += a[r]

    if r >= n:
        r = 0
    if l >= n:
        l = 0
#print(l,r,q)
uoi = r+1
if uoi >= n:
    uoi = 0
w = a[uoi]
l2 = uoi
r2 = uoi
#print(l2,r2)
while w != tru:
    #print(w)
    if w < tru:
        r2 += 1
        if r2+1>=n:
            r2 = 0
        w += a[r2]

    if w > tru:
        w -= a[l2]
        l2+=1
        if l2>r2:
            r2 += 1
            q += a[r2]

    if r2 >= n:
        r2 = 0
    if l2 >= n:
        l2 = 0
    #print('r2',r2)
#print(l2,r2,w)
uoi2 = r2+1
if uoi >= n:
    uoi = 0

print(vid)
print(l+1,uoi+1,uoi2+1)