Solve in Python:
Let's denote a function 

$d(x, y) = \left\{\begin{array}{ll}{y - x,} & {\text{if}|x - y|> 1} \\{0,} & {\text{if}|x - y|\leq 1} \end{array} \right.$

You are given an array a consisting of n integers. You have to calculate the sum of d(a_{i}, a_{j}) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.


-----Input-----

The first line contains one integer n (1 ≤ n ≤ 200000) — the number of elements in a.

The second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — elements of the array. 


-----Output-----

Print one integer — the sum of d(a_{i}, a_{j}) over all pairs (i, j) such that 1 ≤ i ≤ j ≤ n.


-----Examples-----
Input
5
1 2 3 1 3

Output
4

Input
4
6 6 5 5

Output
0

Input
4
6 6 4 4

Output
-8



-----Note-----

In the first example:

  d(a_1, a_2) = 0;  d(a_1, a_3) = 2;  d(a_1, a_4) = 0;  d(a_1, a_5) = 2;  d(a_2, a_3) = 0;  d(a_2, a_4) = 0;  d(a_2, a_5) = 0;  d(a_3, a_4) =  - 2;  d(a_3, a_5) = 0;  d(a_4, a_5) = 2.
N = 2 * 10**5 + 3
n = int(input())
A, cnt = list(map(int,input().split(' '))), {}

s, a = 0, 0

for i in range(n-1,-1,-1):
    a += s
    if (A[i]-1) in cnt:
        a += cnt[A[i]-1]
    if (A[i]+1) in cnt:
        a -= cnt[A[i]+1]
    a -= (n-(i+1))*A[i]
    s += A[i]
    if A[i] not in cnt:
        cnt[A[i]]=0
    cnt[A[i]] += 1

print(a)