Problem Statement
Given is a number sequence A of length N.
Find the sum of squared differences of every pair of elements: displaystylesumi=2Nsumj=1i−1(Ai−Aj)2.
Constraints
- 2leNle3times105
- ∣Ai∣le200
- All values in input are integers.
Input is given from Standard Input in the following format:
N
A1 A2 A3 cdots AN
Output
Print the answer.
Sample Output 1
We have sumi=2Nsumj=1i−1(Ai−Aj)2=(8−2)2+(4−2)2+(4−8)2=56.
Sample Output 2