Sum of differences#12231

Sum of differences

1 second
128 megabytes
Easy

Given integers a_1, a_2, \ldots, a_n.

Compute the value of the sum:

\sum_{i=1}^{n-1} \sum_{j=i+1}^{n} \lvert a_i - a_j \rvert,

that is, the sum of absolute differences over all pairs of indices such that 1 \le i < j \le n.

Input

The first line contains a single integer n~(2 \le n \le 2 \times 10^5).

The second line contains integers a_1, a_2, \ldots, a_n~(\lvert a_i \rvert \le 10^8).

Output

Print a single integer — the required sum.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading