sma=0
def aa(l0):
    global sma
    l,t,sm=l0,l0,0
    while(sm!=sma//3 and t<n):
        if(sm<sma//3):
            sm+=a[t]
            t+=1
        else:
            sm-=a[l]
            l+=1
    sm2=0
    t2=t
    while(sm2<sma//3):
        t2=t2%n
        sm2+=a[t2]
        t2=(t2+1)
    return [max(sm,sm2,sma-sm-sm2)-min(sm,sm2,sma-sm-sm2),l,t,t2]
n = int(input())
a=list(map(int,input().split()))
sma=sum(a)
ans=aa(0)
l=ans[1]+1
while(ans[0]>0):
    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)