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))
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
ex = []
temp = 0
a.append(0)
for i in range(n-1):
    if start == n:
        start = 0
    temp += a[start]
    if is_closer(temp, temp+a[start+1], summ):
        ex.append(start)
        start += 1
        temp = 0
    else:
        start += 1
for i in ex:
    print(i, end=' ')