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>
const int N = 2 * 1e5 + 1;
const int M = 1e6 + 1;
const int inf = 1e9;
const int base = 1e9 + 7;
using namespace std;
long double n, a[N], t[4 * N], k[4 * N];
long double ans = 0;
vector<int> vv;
map<int, bool> ms;
void add(int x) {
  if (!ms[x]) {
    ms[x] = true;
    vv.push_back(x);
  }
}
long double get_kol(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) return k[v];
  int tm = (tl + tr) / 2;
  return get_kol(v * 2, tl, tm, l, min(r, tm)) +
         get_kol(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r);
}
long double get_sum(int v, int tl, int tr, int l, int r) {
  if (l > r) return 0;
  if (tl == l && tr == r) return t[v];
  int tm = (tl + tr) / 2;
  return get_sum(v * 2, tl, tm, l, min(r, tm)) +
         get_sum(v * 2 + 1, tm + 1, tr, max(tm + 1, l), r);
}
void mod(int v, int tl, int tr, int pos, int val) {
  if (tl == tr) {
    k[v]++;
    t[v] += val;
    return;
  }
  int tm = (tl + tr) / 2;
  if (pos <= tm)
    mod(v * 2, tl, tm, pos, val);
  else
    mod(v * 2 + 1, tm + 1, tr, pos, val);
  k[v] = k[v * 2] + k[v * 2 + 1];
  t[v] = t[v * 2] + t[v * 2 + 1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    add(a[i]);
  }
  sort(vv.begin(), vv.end());
  for (int i = 0; i < n; i++) {
    int pos1 = upper_bound(vv.begin(), vv.end(), a[i]) - vv.begin() - 1;
    int pos2, pos3;
    pos2 = pos3 = pos1;
    long double kol1 = 0, kol2 = 0, sum1 = 0, sum2 = 0;
    while (pos3 < vv.size() && abs(vv[pos3] - a[i]) < 2) pos3++;
    while (pos2 >= 0 && abs(vv[pos2] - a[i]) < 2) pos2--;
    if (pos2 >= 0) {
      kol1 = get_kol(1, 0, vv.size() - 1, 0, pos2);
      sum1 = get_sum(1, 0, vv.size() - 1, 0, pos2);
    }
    if (pos3 < vv.size()) {
      kol2 = get_kol(1, 0, vv.size() - 1, pos3, vv.size() - 1);
      sum2 = get_sum(1, 0, vv.size() - 1, pos3, vv.size() - 1);
    }
    ans += (a[i] * kol1) - sum1;
    ans += (a[i] * kol2) - sum2;
    mod(1, 0, vv.size() - 1, pos1, a[i]);
  }
  cout << fixed << setprecision(0) << ans;
}
