import sys
n = int(sys.stdin.readline())
m = list(map(int,sys.stdin.readline().split()))
if n == 3:
    print(max(m) - min(m))
    print("1 2 3")
else:
    print(0)
    f = int(sum(m)/3)
    i = 0
    a = 0
    q = [0,0,0]
    g = 0
    while a < f:
        a += m[g]
        if a > f:
            a -= m[g]
            t = 0
            while a != f:
                a += m[n-t-1]
                t+=1
                q[2] += 1
            break
        g+=1
    q[0] += g
    a = 0
    g = q[0]
    while a < f:
        a += m[g]
        g += 1
    q[1] += g
    a = 0
    q[2] = n - q[2]
    print(str(q[0]+1) + " " + str(q[1]+1) + " " + str(q[2]+1))
        





    
