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:
    a1=[]
    b1=b*10
    for i in range(n):
        st=[]
        bn = 0
        for j in range(n):
            a2=[]
            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))
                st.clear()
                bn+=1
            if bn==3:
                a1.append(a2)
                break
    c=[]
    for i in a1:
        c.append(i[0])
    c.sort()
    print(0)
    print(c[0],c[1],c[2])