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

# O(n^2) = 2/3 * n<10^6

prefix_sum = [0 for _ in range(n+1)]
prefix_sum[0]=a[0]
prefix_sum[-1]=0
for i in range(1,n):
    prefix_sum[i] = prefix_sum[i-1]+a[i]

ave = prefix_sum[-2]//3 # revivus



xg,yg,zg = 0,0,0
xs,ys,zs = 0,0,0
res = False

for start in range(1  , n-2):
  # print('start', start)
    for dx in range(start, n-2):
     #  print('dx', dx,  prefix_sum[dx]-prefix_sum[start])
        if(prefix_sum[dx]-prefix_sum[start-1]==ave):
            for dy in range(dx+1, n-1):
              # print('dy', dy, prefix_sum[dy]-prefix_sum[dx+1])
                if(prefix_sum[dy]-prefix_sum[dx+1]==ave):
                    print(start,dx+1, dy+1)
                    res = True
                    break
        if(res):
            break
    if(res):
        break
