#ABC194C. [ABC194C] Squared Error

[ABC194C] Squared Error

提示:该题测试数据补录中,暂不支持评测提交。

No testdata at current.

No submission language available for this problem.

Score : 300300 points

Problem Statement

Given is a number sequence AA of length NN. Find the sum of squared differences of every pair of elements: $\displaystyle \sum_{i = 2}^{N} \sum_{j = 1}^{i - 1} (A_i - A_j)^2$.

Constraints

  • 2≤N≤3×1052 \le N \le 3 \times 10^5
  • ∣Ai∣≤200|A_i| \le 200
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 A3A_3 ⋯\cdots ANA_N

Output

Print the answer.

3
2 8 4
56

We have $\sum_{i = 2}^{N} \sum_{j = 1}^{i - 1} (A_i - A_j)^2 = (8 - 2)^2 + (4 - 2) ^ 2 + (4 - 8) ^ 2 = 56$.

5
-5 8 9 -4 -3
950