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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
using namespace std;
const int N = 2e5 + 10;
int a[N], tot;
int ls[N * 33], rs[N * 33], cnt[N * 33];
long long val[N * 33];
void update(int p, int l, int r, int &rt) {
  if (!rt) rt = ++tot;
  if (l == r) {
    cnt[rt]++;
    val[rt] += p;
    return;
  }
  int m = (l + r) / 2;
  if (p <= m)
    update(p, l, m, ls[rt]);
  else
    update(p, m + 1, r, rs[rt]);
  cnt[rt] = cnt[ls[rt]] + cnt[rs[rt]];
  val[rt] = val[ls[rt]] + val[rs[rt]];
}
pair<long long, long long> query(int L, int R, int l, int r, int rt) {
  if (!rt) return pair<long long, long long>(0, 0);
  if (L <= l && r <= R) return pair<long long, long long>(val[rt], cnt[rt]);
  pair<long long, long long> ans = pair<long long, long long>(0, 0);
  int m = (l + r) / 2;
  if (L <= m) {
    pair<long long, long long> t = query(L, R, l, m, ls[rt]);
    ans.first += t.first, ans.second += t.second;
  }
  if (R > m) {
    pair<long long, long long> t = query(L, R, m + 1, r, rs[rt]);
    ans.first += t.first, ans.second += t.second;
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  int rt = 0;
  long long ans = 0, sum = 0;
  unsigned long long x = 0, y = 0;
  for (int i = n; i >= 1; i--) {
    pair<long long, long long> t = query(a[i] - 1, a[i] + 1, 0, 1e9 + 10, rt);
    ans = (sum - t.first) - a[i] * (n - i - t.second);
    if (ans < 0)
      y += (-ans);
    else
      x += ans;
    sum += a[i];
    update(a[i], 0, 1e9 + 10, rt);
  }
  if (x >= y)
    cout << x - y << endl;
  else
    cout << "-" << y - x << endl;
}
