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 long long md = 1e9 + 7;
const int Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 1e9 + 1;
const long long LogN = 20;
const long long MaxM = 1e10;
const long double eps = 1e-7;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
const long long ddx[4] = {1, 1, -1, -1};
const long long ddy[4] = {1, -1, 1, -1};
const long double Pi = acos(-1);
using namespace std;
inline long long Mod(long long &a, long long m = md) {
  while (a > m) a -= m;
  return a;
}
inline long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
inline long long gcdex(long long a, long long mod = md) {
  long long g = mod, r = a, x = 0, y = 1;
  while (r != 0) {
    long long q = g / r;
    g %= r;
    swap(g, r);
    x -= q * y;
    swap(x, y);
  }
  return x < 0 ? x + mod : x;
}
inline long long binpow(long long a, long long n, long long m = md) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= m;
    }
    a *= a;
    a %= m;
    n >>= 1;
  }
  return res % md;
}
struct Vert {
  Vert() {
    Sum = 0;
    l = NULL;
    r = NULL;
  }
  Vert(Vert *tl, Vert *tr) {
    l = tl;
    r = tr;
    Sum = l->Sum + r->Sum;
  }
  long double Sum = 0;
  Vert *l, *r;
};
Vert *Sum = new Vert();
Vert *Cnt = new Vert();
void AddCnt(long long l, long long r, long long x, Vert *t) {
  if (l > r) return;
  if (l == r) {
    t->Sum++;
  } else {
    long long mid = (l + r) / 2;
    if (x <= mid) {
      if (t->l == NULL) {
        t->l = new Vert();
      }
      AddCnt(l, mid, x, t->l);
    } else {
      if (t->r == NULL) {
        t->r = new Vert();
      }
      AddCnt(mid + 1, r, x, t->r);
    }
    long long w = 0;
    if (t->l != NULL) w += t->l->Sum;
    if (t->r != NULL) w += t->r->Sum;
    t->Sum = w;
  }
}
void AddSum(long long l, long long r, long long x, Vert *t) {
  if (l > r) return;
  if (l == r) {
    t->Sum += x;
  } else {
    long long mid = (l + r) / 2;
    if (x <= mid) {
      if (t->l == NULL) {
        t->l = new Vert();
      }
      AddSum(l, mid, x, t->l);
    } else {
      if (t->r == NULL) {
        t->r = new Vert();
      }
      AddSum(mid + 1, r, x, t->r);
    }
    long long w = 0;
    if (t->l != NULL) w += t->l->Sum;
    if (t->r != NULL) w += t->r->Sum;
    t->Sum = w;
  }
}
long double get(long long l, long long r, long long x, long long y, Vert *t) {
  if (l > r) return 0;
  if (x > y) return 0;
  if (l == x && y == r) {
    return t->Sum;
  } else {
    long long mid = (l + r) / 2;
    if (y <= mid) {
      if (t->l == NULL) return 0;
      return get(l, mid, x, y, t->l);
    } else if (mid + 1 <= x) {
      if (t->r == NULL) return 0;
      return get(mid + 1, r, x, y, t->r);
    } else {
      long long w = 0;
      if (t->l != NULL) w += get(l, mid, x, mid, t->l);
      if (t->r != NULL) w += get(mid + 1, r, mid + 1, y, t->r);
      return w;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed, cout.precision(0);
  long long N;
  cin >> N;
  long double Ans = 0;
  long double Kl = 0;
  long double Ch = 0;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    long double l = get(0, MaxN, a + 2, MaxN, Cnt);
    long double r = get(0, MaxN, 0, a - 2, Cnt);
    Kl = l + r;
    Ch = get(0, MaxN, a + 2, MaxN, Sum) + get(0, MaxN, 0, a - 2, Sum);
    Ans += a * Kl - Ch;
    AddCnt(0, MaxN, a, Cnt);
    AddSum(0, MaxN, a, Sum);
  }
  cout << Ans;
  cerr << '\n'
       << "Time execute: " << clock() / (double)CLOCKS_PER_SEC << " sec"
       << '\n';
  return 0;
}
