atcoder#ABC186D. [ABC186D] Sum of difference
[ABC186D] Sum of difference
Score : points
Problem Statement
Given are integers .
Find the sum of over all pairs such that .
In other words, find $\displaystyle{\sum_{i=1}^{N-1}\sum_{j=i+1}^{N} |A_i-A_j|}$.
Constraints
- is an integer.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
5 1 2
8
We have .
5
31 41 59 26 53
176