def aa(l0):
    l,t,sm=l0,l0,0
    while(sm!=sum(a)//3 and t<n):
        if(sm<sum(a)//3):
            sm+=a[t]
            t+=1
        else:
            sm-=a[l]
            l+=1
    sm2=0
    t2=t
    while(sm2<sum(a)//3):
        t2=t2%n
        sm2+=a[t2]
        t2=(t2+1)
    return [max(sm,sm2,sum(a)-sm-sm2)-min(sm,sm2,sum(a)-sm-sm2),l,t,t2]
n = int(input())
a=list(map(int,input().split()))
ans=aa(0)
l=ans[1]+1
while(l<n):
    ans2=aa(l)
    l=ans2[1]+1
    if(ans2[0]<ans[0]):ans=ans2
print(ans[0])
print(ans[1]+1,ans[2]+1,ans[3]+1)