#CCBCHBAHAI0000089. Tổng có trọng số theo vị trí

    ID: 1007 Loại: Thông thường 2000ms 256MiB Tried: 0 Đã chấp nhận: 0 Độ khó: 1 Đăng bởi: Nhãn>Programming language basicsStatic arraysIteration techniquesImplementation techniquesWorking with numbersInteger arithmetic

Tổng có trọng số theo vị trí

Position-Weighted Sum

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given a0,a1,…,an−1a_0,a_1,\ldots,a_{n-1}, compute the 1-based position-weighted sum

S=∑i=0n−1(i+1)ai.\boxed{S=\sum_{i=0}^{n-1}(i+1)a_i}.

Use a 64-bit accumulator.

Input

The first line contains nn. The second line contains nn integers aia_i.

Output

Print SS.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, ∣ai∣≤103|a_i|\le10^3.

Subtask 2 (30 points): 1≤n≤10001\le n\le1000, ∣ai∣≤106|a_i|\le10^6.

Subtask 3 (50 points): 1≤n≤1051\le n\le10^5, ∣ai∣≤109|a_i|\le10^9.

Example

Input

4
3 -2 5 1

Output

18

Explanation

The result follows directly from the mathematical definition above.