import itertools n = int(input()) N = [int(x) for x in range(0,n)] A = [int(x) for x in input().split()] ans = sum(A) C = list(itertools.combinations(N,2)) for i,j in C: ans += sum(A[i:j+1]) print(ans)