from sys import stdin
n = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
x = 0
y = n//3
z = 2*y
sx=sum(a[x:y])
sy=sum(a[y:z])
sz = sum(a[z:n])
max_diff = n % 3
diff = max(sx, sy, sz) - min(sx, sy, sz)
changed = True
while True:
    if not changed:
        break
    changed=False
    x, y, z = x%n, y%n, z%n
    ma = max(sx, sy, sz)
    mi = min(sx, sy, sz)

    if sx == mi and sy == ma:
        if sx < sy and x +1!=y:
            if sy - sx >=  a[y]:
                
                sx+= a[y]
                sy-= a[y]
                y+=1
                changed=True
                continue
    if sx == mi and sz == ma:
        if sx < sz and z +1!=x+n:
            if sz - sx >= a[x-1]:
            
                sx+= a[x-1]
                sz-= a[x-1]
                x-=1
                changed=True
                continue
        #
    if sy== mi and sz == ma:
        if sy < sz and y +1!=z:
            if sz - sy >=  a[z]:
                
                sy+= a[z]
                sz-= a[z]
                z+=1
                changed=True
                continue
    if sy == mi and sx == ma:
        if sy < sx and x +1!=y:
            if sx - sy >=  a[y-1]:
                
                sy+= a[y-1]
                sx-= a[y-1]
                y-=1
                changed=True
                continue
        #
    if sz == mi and sx == ma:
        if sz < sx and z +1!=x+n:
            if sx - sz >=  a[x]:
                
                sz+= a[x]
                sx-= a[x]
                x+=1
                changed=True
                continue
    if sz == mi and sy == ma:
        if sz < sy and y + 1!=z:
            if sy - sz >= a[z-1]:
                
                sz+= a[z-1]
                sy-= a[z-1]
                z-=1
                changed=True
                continue
  #--------------------------------------------------------------------------
    if sx != ma:
        if sx < sy and x +1!=y:
            if sy - sx >=  a[y]:
                
                sx+= a[y]
                sy-= a[y]
                y+=1
                changed=True
                continue
        if sx < sz and z +1!=x+n:
            if sz - sx >= a[x-1]:
            
                sx+= a[x-1]
                sz-= a[x-1]
                x-=1
                changed=True
                continue
    #
    if sy== mi:
        if sy < sz and y +1!=z:
            if sz - sy >=  a[z]:
                
                sy+= a[z]
                sz-= a[z]
                z+=1
                changed=True
                continue
        if sy < sx and x +1!=y:
            if sx - sy >=  a[y-1]:
                
                sy+= a[y-1]
                sx-= a[y-1]
                y-=1
                changed=True
                continue
    #
    if sz == mi:
        if sz < sx and z +1!=x+n:
            if sx - sz >=  a[x]:
                
                sz+= a[x]
                sx-= a[x]
                x+=1
                changed=True
                continue
        if sz < sy and y + 1!=z:
            if sy - sz >= a[z-1]:
                
                sz+= a[z-1]
                sy-= a[z-1]
                z-=1
                changed=True
                continue
     #--------------------------------------------------------------------------------
    if sx < sy and x +1!=y:
        if sy - sx >=  a[y]:
            
            sx+= a[y]
            sy-= a[y]
            y+=1
            changed=True
            continue
    if sx < sz and z +1!=x+n:
        if sz - sx >= a[x-1]:
           
            sx+= a[x-1]
            sz-= a[x-1]
            x-=1
            changed=True
            continue
    #
    if sy < sz and y +1!=z:
        if sz - sy >=  a[z]:
            
            sy+= a[z]
            sz-= a[z]
            z+=1
            changed=True
            continue
    if sy < sx and x +1!=y:
        if sx - sy >=  a[y-1]:
            
            sy+= a[y-1]
            sx-= a[y-1]
            y-=1
            changed=True
            continue
    #
    if sz < sx and z +1!=x+n:
        if sx - sz >=  a[x]:
            
            sz+= a[x]
            sx-= a[x]
            x+=1
            changed=True
            continue
    if sz < sy and y + 1!=z:
        if sy - sz >= a[z-1]:
            
            sz+= a[z-1]
            sy-= a[z-1]
            z-=1
            changed=True
            continue

print(max(sx, sy, sz) - min(sx, sy, sz))
for i in sorted([x+1, y+1, z+1]):
    print(i, end=" ")