import math
n = int(input())
active = list(map(int,input().split()))
list = [0 for i in range(n)]
counter = 0
sum = 0
for i in list:
    if i == 1:
        continue
    max = [0,0,0]
    for j in range(n):
        if j == counter or list[j] == 1:
            continue
        temp = (active[counter]+active[j])*abs(counter - j)
        if temp > max[0]:
            max = [temp,j,counter]
    sum += max[0]
    print(sum)
    list[max[1]] = 1
    list[max[2]] = 1
    counter += 1
    print(list)

print(sum)
