def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): N=I() A=LI() def sum2(x): return (x*(x+1))//2 def calc(k):#k番目 temp=sum2(k-1)*2 temp+=k*(N-(k-1)*2) return temp ans=0 B=[0]*N for i in range(N): d=calc(min(i+1,N-i)) B[i]=A[i]*d print(sum(B)) main()