n=int(input())
a=input().split()
b=[]
for i in a:
    b.append(int(i))
avr=sum(b)//3
if n==3:
    print(max(b)-min(b))
    print(1,2,3)
else:
    fl=False
    a1=[]
    b1=b*10
    for i in range(n):
        a2=[]
        st=[]
        bn = 0
        for j in range(n):
            
            st.append(b1[j+i])
            if sum(st)>avr:
                st.clear()
                continue
            elif sum(st)==avr:
                a2.append((j+i+2-len(st))%len(b))
                #print((j+i+2-len(st))%len(b))
                #print(a2)
                st.clear()
                bn+=1
            if bn==3:
                fl=True
                a1.append(a2)
                #print(a1)
                break
        if fl:
            break
    c=[]
    for i in range(3):
        c.append(a1[0][i])
    c.sort()
    print(0)
    print(c[0],c[1],c[2])