n=int(input()) a=list(map(int,input().split())) a=a+[0] b=[0]*(n+1) s=0 for i in range(n)[::-1]: t=(n-i)*a[i]+b[i+1] b[i]=t s+=t print(s)