n=int(input())
a = list(input().split())
for i in range(n):
    a[i] = int(a[i])
summ = sum(a)
summ = summ // 3
start = a.index(max(a))
s = a.index(max(a))
def is_closer(a,b,c):
    a_diff = c-a
    b_diff = c-b
    if a_diff < 0:
        a_diff *= -1
    if b_diff < 0:
        b_diff *= -1
    if a_diff <b_diff:
        return True
    else:
        return False
b = []
for i in range(n):
    if start + i == n:
        start -= start+i
    b.append(a[start+i])
ex = []
start = 0
temp = 0
b.append(0)
count = 0
maxis = []
for i in range(n):
    temp += b[i]
    if is_closer(temp, temp+b[i+1], summ) and b[i+1] != 0:
       ex.append(start)
       count += 1
       start = i+1
       maxis.append(temp)
       temp = 0
    if i == n-1 and len(ex) == 2:
        maxis.append(temp)
        ex.append(start)
f = []
for i in ex:
    if i + s < n:
        f.append(i+s+1)
    else:
        f.append(i+s-n+1)
f.sort()
print(max(maxis)-min(maxis))
for i in f:
    print(i, end=' ')
