N=int(input()) A=list(map(int,input().split())) s=t=0 for i in range(N): s+=N-2*i t+=s*A[i] print(t)