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;
long long int n, lim = -1e18;
long long int ar[200200], tree1[3000000], tree2[3000000];
map<long long int, long long int> rev;
inline void update1(long long int nd, long long int s, long long int e,
                    long long int idx, long long int val) {
  if (s == e) {
    tree1[nd] += val;
    return;
  }
  long long int m = (s + e) / 2;
  if (idx <= m)
    update1(2 * nd + 1, s, m, idx, val);
  else
    update1(2 * nd + 2, m + 1, e, idx, val);
  tree1[nd] = tree1[2 * nd + 1] + tree1[2 * nd + 2];
}
inline long long int query1(long long int nd, long long int s, long long int e,
                            long long int l, long long int r) {
  if (r < l || r < s || e < l) return 0;
  if (l <= s && e <= r) return tree1[nd];
  long long int m = (s + e) / 2;
  return (query1(2 * nd + 1, s, m, l, r) + query1(2 * nd + 2, m + 1, e, l, r));
}
inline void update2(long long int nd, long long int s, long long int e,
                    long long int idx, long long int val) {
  if (s == e) {
    tree2[nd] += val;
    return;
  }
  long long int m = (s + e) / 2;
  if (idx <= m)
    update2(2 * nd + 1, s, m, idx, val);
  else
    update2(2 * nd + 2, m + 1, e, idx, val);
  tree2[nd] = tree2[2 * nd + 1] + tree2[2 * nd + 2];
}
inline long long int query2(long long int nd, long long int s, long long int e,
                            long long int l, long long int r) {
  if (r < l || r < s || e < l) return 0;
  if (l <= s && e <= r) return tree2[nd];
  long long int m = (s + e) / 2;
  return (query2(2 * nd + 1, s, m, l, r) + query2(2 * nd + 2, m + 1, e, l, r));
}
inline void compress() {
  set<long long int> st;
  for (long long int i = 0; i < n; i++) st.insert(ar[i]);
  map<long long int, long long int> mp;
  long long int prev = -10;
  mp[-10] = 0;
  for (auto it : st) {
    if (it - prev == 1)
      mp[it] = mp[prev] + 1;
    else
      mp[it] = mp[prev] + 2;
    rev[mp[it]] = it;
    prev = it;
  }
  for (long long int i = 0; i < n; i++) {
    ar[i] = mp[ar[i]];
    lim = max(lim, ar[i]);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(tree1, 0, sizeof(tree1));
  memset(tree2, 0, sizeof(tree2));
  long double ans = 0;
  cin >> n;
  for (long long int i = 0; i < n; i++) cin >> ar[i];
  compress();
  for (long long int i = n - 1; i >= 0; i--) {
    long long int freq =
        query1(0, 0, lim, ar[i] + 2, lim) + query1(0, 0, lim, 0, ar[i] - 2);
    long long int sum =
        query2(0, 0, lim, ar[i] + 2, lim) + query2(0, 0, lim, 0, ar[i] - 2);
    ans = ans + sum - freq * rev[ar[i]];
    update1(0, 0, lim, ar[i], 1);
    update2(0, 0, lim, ar[i], rev[ar[i]]);
  }
  cout << fixed << setprecision(0);
  cout << ans;
  return 0;
}
