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