def accumulate_sum(start: int, end: int) -> int: if start > end: return 0 return (end * (end + 1) - start * (start - 1)) // 2 def main(): N = int(input()) A = list(map(int, input().split())) if N == 1: print(A[0]) return coefficients = [] if N % 2 == 0: for t in range(1, N//2 + 1): coefficients.append(2*(N//2 - t)*t + 2*accumulate_sum(1, t)) coeff_rev = reversed(coefficients) coefficients.extend(coeff_rev) else: for t in range(1, (N+1)//2): coefficients.append(t*(N - 2*(t-1)) + 2*accumulate_sum(1, t-1)) coeff_rev = reversed(coefficients) coefficients.append((N+1)//2 + 2*accumulate_sum(1, (N+1)//2 - 1)) coefficients.extend(coeff_rev) print(sum(A_elm * coeff for A_elm, coeff in zip(A, coefficients))) # Nが奇数 (N+1)//2=nとすると # 中央 n*1 + 2*sum(1, n-1) # 一つ横 (n-1)*3 + 2*sum(1, n-2) # 二つ横 (n-2)*5 + 2*sum(1,n-3) # Nが偶数 N//2=nとすると # 中央 # 中央2つ n*0 + 2*sum(1,n) # 一つ横 (n-1)*2 + 2*sum(1,n-1) if __name__ == "__main__": main()