N = int(input())
A = list(map(int,input().split()))
a = len(A)
output = 0
index = 0
m = 1
l = a / 2
for i in range(1,a+1) :
    if m + l > a :
        n = m - l
    elif m + l <= a :
        n = m + l
    output +=  A[index] * abs(m-n)
    index += 1
    m += 1
print(output)