Problem5148--Math

5148: Math

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

Give you n number $a_{1},a_{2},\cdots,a_{n}$, for all i, j (1 ≤ i ≤ j ≤ n), calculate the sum of $a_{i}\ast a_{j}$.

Input

For each input, the first line is a number n ($n < 100000$).
The second line has n number $a_{1},a_{2},\cdots,a_{n}$, ($a_{i}<1000$).

Output

Print the sum of $a_{i}\ast a_{j}$. ($1\leqslant i\leqslant j\leqslant n$).

Sample 1 Input

2
2 3

Sample 1 Output

19

HINT

【样例说明】
In the first case, $2*2 + 3*2 + 3*3 = 4 + 6 + 9 = 19$.

Source/Category

基础算法 4.2.前缀和