n = int(input()) a = list(map(int, input().split())) s = sum(a) total = 0 t = n//2 if n % 2 == 0 else n//2+1 total = s*n df = 0 for i in range(1, t): df += a[i-1] + a[-i] total += (s - df) * (n-2*i) print(total)