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;
const int Z = (int)2e5 + 111;
const int inf = (int)1e9 + 111;
const long long llinf = (long long)1e18 + 5;
const int MOD = (int)1e9 + 7;
vector<long long> pref[4 * Z];
vector<int> t[4 * Z];
int a[Z];
void build(int v, int vl, int vr) {
  if (vl == vr) {
    t[v].push_back(a[vl]);
    pref[v].push_back(a[vl]);
    return;
  }
  int vm = (vl + vr) / 2;
  build(2 * v, vl, vm);
  build(2 * v + 1, vm + 1, vr);
  merge((t[2 * v]).begin(), (t[2 * v]).end(), (t[2 * v + 1]).begin(),
        (t[2 * v + 1]).end(), back_inserter(t[v]));
  pref[v].resize((int)t[v].size());
  pref[v][0] = t[v][0];
  for (int i = 1; i < (int)t[v].size(); ++i) {
    pref[v][i] = pref[v][i - 1] + t[v][i];
  }
}
pair<long long, long long> query(int v, int vl, int vr, int l, int r, int val1,
                                 int val2) {
  if (vl > r || vr < l) return make_pair(0, 0);
  if (l <= vl && r >= vr) {
    long long cnt = upper_bound((t[v]).begin(), (t[v]).end(), val2) -
                    lower_bound((t[v]).begin(), (t[v]).end(), val1);
    int posL = lower_bound((t[v]).begin(), (t[v]).end(), val1) - t[v].begin();
    int posR = upper_bound((t[v]).begin(), (t[v]).end(), val2) - t[v].begin();
    posR--;
    long long sum;
    if (posR == -1)
      sum = 0;
    else
      sum = pref[v][posR] - (posL == 0 ? 0 : pref[v][posL - 1]);
    return make_pair(sum, cnt);
  }
  int vm = (vl + vr) / 2;
  pair<long long, long long> ql = query(2 * v, vl, vm, l, r, val1, val2);
  pair<long long, long long> qr =
      query(2 * v + 1, vm + 1, vr, l, r, val1, val2);
  return make_pair(ql.first + qr.first, ql.second + qr.second);
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  build(1, 1, n);
  long double ans = 0;
  for (int i = 1; i <= n; ++i) {
    pair<long long, long long> l;
    if (a[i] - 2 >= 1)
      l = query(1, 1, n, i + 1, n, 1, a[i] - 2);
    else
      l = make_pair(0, 0);
    pair<long long, long long> r = query(1, 1, n, i + 1, n, a[i] + 2, inf);
    ans += l.first + r.first - (l.second + r.second) * a[i];
  }
  cout << fixed << setprecision(0) << ans;
  return 0;
}
