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

if n == 3:
    print(max(a) - min(a))
    print("1 2 3")
elif max(a)==0:
    print(0)
    print("1 2 3")
elif max(a)==1:
    suma = sum(a)
    if sum(a) % 3==0:
        print(0)
        res = (suma - suma % 3) // 3
    else:
        print(1)
        res = (suma - suma % 3) // 3 +1
    # print(3 - sum(a) % 3)
    
    

    # print(res)
    # print((suma - suma % 3) / 3)
    # if res < (suma - suma % 3) / 3: res = 1
    # print(res)
    # print(a)
    rez = 0
    resy = 0
    while rez < res:
        # print("----")
        # print(rez)
        # print(resy)
        rez += a[resy]
        resy += 1
    rez = 0
    resz = resy
    while rez < res:
        rez += a[resy]
        resz += 1
    
    # print(3 - suma % 3)
    print(1, resy+1, resz+1)
elif sum(a)%3==0:
    r=sum(a)//3
    print(0)
    i=0
    while i<n:
        # print("i",i)
        j=i+1
        if i==0:
            maxj=n-2
        elif i==1:
            maxj=n-1
        elif i==2:
            maxj=n
        else:
            maxj=i-2
        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!=i-1:

                    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

else:
    print()
