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;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const long long N = 200100;
const long long inf = (1LL << 62);
long long a[N];
vector<long long> imprime(__int128 x) {
  if (x == (__int128)0) {
    vector<long long> r;
    r.push_back(0);
    return r;
  }
  vector<long long> r;
  if (x < 0) {
    cout << "-";
    x = -x;
  }
  while (x >= (__int128)1) {
    r.push_back((long long)(x % (__int128)10));
    x /= (__int128)10;
  }
  reverse(r.begin(), r.end());
  return r;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  map<long long, long long> mp;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  __int128 res = 0;
  long long pre = 0;
  for (long long i = n; i >= 1; i--) {
    res += pre - 1ll * (n - i) * a[i];
    res -= (mp[a[i] - 1] * (-1 - 0));
    res -= (mp[a[i] + 1] * 1);
    mp[a[i]]++;
    pre += a[i];
  }
  vector<long long> v = imprime(res);
  for (auto x : v) cout << x;
  cout << "\n";
}
