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 long long M = 1E9 + 7;
const long long NMAX = 222222;
const long long inf = 1000000000;
const long double eps = 1E-5;
map<long long, long long> com;
long long a[NMAX];
long long decom[NMAX];
long long tsz[NMAX * 4];
long long tsum[NMAX * 4];
void updata(long long v, long long tl, long long tr, long long pos,
            long long val) {
  if (pos < tl || pos >= tr) return;
  if (tr == tl + 1) {
    tsz[v]++;
    tsum[v] += val;
    return;
  }
  long long m = (tl + tr) / 2;
  updata(2 * v, tl, m, pos, val);
  updata(2 * v + 1, m, tr, pos, val);
  tsz[v] = tsz[2 * v] + tsz[2 * v + 1];
  tsum[v] = tsum[2 * v] + tsum[2 * v + 1];
  return;
}
long long getsz(long long v, long long tl, long long tr, long long l,
                long long r) {
  if (tl >= r || tr <= l) return 0;
  if (tl == l && tr == r) {
    return tsz[v];
  }
  long long m = (tl + tr) / 2;
  return getsz(2 * v, tl, m, l, min(r, m)) +
         getsz(2 * v + 1, m, tr, max(l, m), r);
}
long long getsum(long long v, long long tl, long long tr, long long l,
                 long long r) {
  if (tl >= r || tr <= l) return 0;
  if (tl == l && tr == r) {
    return tsum[v];
  }
  long long m = (tl + tr) / 2;
  return getsum(2 * v, tl, m, l, min(r, m)) +
         getsum(2 * v + 1, m, tr, max(l, m), r);
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout.tie(0);
  cout.precision(40);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    com[a[i]] = 0;
  }
  long long j = 1;
  for (pair<long long, long long> e : com) {
    com[e.first] = j;
    decom[j] = e.first;
    j++;
  }
  unsigned long long ansp = 0, anso = 0;
  for (long long i = 1; i <= n; i++) {
    long long b = com[a[i]];
    if (decom[b] - decom[b - 1] == 1)
      ansp +=
          getsz(1, 1, n + 1, 1, b - 1) * a[i] - getsum(1, 1, n + 1, 1, b - 1);
    else
      ansp += getsz(1, 1, n + 1, 1, b) * a[i] - getsum(1, 1, n + 1, 1, b);
    if (decom[b + 1] - decom[b] == 1)
      anso += -getsz(1, 1, n + 1, b + 2, n + 1) * a[i] +
              getsum(1, 1, n + 1, b + 2, n + 1);
    else
      anso += -getsz(1, 1, n + 1, b + 1, n + 1) * a[i] +
              getsum(1, 1, n + 1, b + 1, n + 1);
    updata(1, 1, n + 1, b, a[i]);
  }
  if (ansp >= anso)
    cout << ansp - anso;
  else
    cout << '-' << anso - ansp;
  return 0;
};
