from multiprocessing.managers import all_methods

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

sm = []

f = 0

for x in range(n-2):
    for y in range(x+1,n):

        for z in range(y+1,n):
                A = sum(a[x:y])
                B = sum(a[y:z])
                C = sum(a[z:n])
                if x > 0:
                    C += sum(a[0:x])
                #print(x,y,z,A,B,C,max([A,B,C])-min([A,B,C]))
                

                sm += [[max([A,B,C])-min([A,B,C]),x+1,y+1,z+1]]

if f == 0:
    sm.sort()
    #print(sm)
    print(sm[0][0])
    print(*sm[0][1:])