Let's denote a function 

<image>

You are given an array a consisting of n integers. You have to calculate the sum of d(ai, aj) 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 a1, a2, ..., an (1 ≤ ai ≤ 109) — elements of the array. 

Output

Print one integer — the sum of d(ai, aj) 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:

  1. d(a1, a2) = 0; 
  2. d(a1, a3) = 2; 
  3. d(a1, a4) = 0; 
  4. d(a1, a5) = 2; 
  5. d(a2, a3) = 0; 
  6. d(a2, a4) = 0; 
  7. d(a2, a5) = 0; 
  8. d(a3, a4) = - 2; 
  9. d(a3, a5) = 0; 
  10. d(a4, a5) = 2. 
#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  scanf("%llu", &n);
  unsigned long long i, j, k, ans = 0, add = 0, sub = 0;
  map<unsigned long long, unsigned long long> cnt, sm, bi;
  unsigned long long num[n], sum[n], aneg = 0, neg = 0;
  scanf("%llu", &num[0]);
  sum[0] = num[0];
  cnt[num[0]] = 1;
  sm[num[0]] = 0;
  bi[num[0]] = 0;
  for (i = 1; i < n; i++) {
    scanf("%llu", &num[i]);
    sum[i] = sum[i - 1] + num[i];
    if (cnt.find(num[i]) == cnt.end()) cnt[num[i]] = 0;
    cnt[num[i]]++;
    if (cnt.find(num[i] - 1) == cnt.end())
      sm[i] = 0;
    else
      sm[i] = cnt[num[i] - 1];
    if (cnt.find(num[i] + 1) == cnt.end())
      bi[i] = 0;
    else
      bi[i] = cnt[num[i] + 1];
  }
  for (i = 1; i < n; i++) {
    add = num[i] * i + bi[i];
    sub = sm[i] + sum[i - 1];
    if (add >= sub) {
      k = add - sub;
      neg = 0;
    } else {
      k = sub - add;
      neg = 1;
    }
    if (aneg == 0) {
      if (neg == 0)
        ans = ans + k;
      else if (k > ans) {
        ans = k - ans;
        aneg = 1;
      } else
        ans = ans - k;
    } else {
      if (neg == 1)
        ans = ans + k;
      else if (k > ans) {
        ans = k - ans;
        aneg = 0;
      } else
        ans = ans - k;
    }
  }
  if (aneg == 1 && ans > 0) printf("-");
  printf("%llu\n", ans);
  return 0;
}
