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 int inf = 0x3f3f3f3f;
const long long infl = 0x3f3f3f3f3f3f3f3fLL;
template <typename T>
inline void umax(T& a, T b) {
  a = max(a, b);
}
template <typename T>
inline void umin(T& a, T b) {
  a = min(a, b);
}
template <typename T>
inline T randIntv(const T& a, const T& b) {
  return (T)rand() % (b - a + 1) + a;
}
void debug() { cout << endl; }
template <typename T, typename... R>
void debug(T f, R... r) {
  cout << "[" << f << "]";
  debug(r...);
}
const int MAXN = 200005;
int n;
long long a[MAXN], f[MAXN << 2], fsz;
long long cnt[MAXN << 2], sum[MAXN << 2];
void update(int x, long long v) {
  while (x <= fsz) {
    cnt[x] += 1;
    sum[x] += v;
    x += x & (-x);
  }
}
pair<long long, long long> query(int x) {
  pair<long long, long long> ret(0, 0);
  while (x > 0) {
    ret.first += cnt[x];
    ret.second += sum[x];
    x -= x & (-x);
  }
  return ret;
}
pair<long long, long long> query(int l, int r) {
  if (l > r) return pair<long long, long long>(0, 0);
  pair<long long, long long> lop = query(l - 1), rop = query(r);
  return pair<long long, long long>(rop.first - lop.first,
                                    rop.second - lop.second);
}
int main() {
  while (~scanf("%d", &n)) {
    fsz = 0;
    for (int i = 1; i <= n; ++i) {
      scanf("%lld", &a[i]);
      f[++fsz] = a[i] - 1;
      f[++fsz] = a[i];
      f[++fsz] = a[i] + 1;
    }
    sort(f + 1, f + fsz + 1);
    fsz = unique(f + 1, f + fsz + 1) - (f + 1);
    for (int i = 0; i <= fsz; ++i) {
      cnt[i] = 0;
      sum[i] = 0;
    }
    long double ans = 0;
    for (int i = 1; i <= n; ++i) {
      int id = lower_bound(f + 1, f + fsz + 1, a[i]) - f;
      update(id, a[i]);
      pair<long long, long long> lop = query(1, id - 2);
      pair<long long, long long> rop = query(id + 2, fsz);
      long long val =
          (lop.first * a[i] - lop.second) + (rop.first * a[i] - rop.second);
      ans += val;
    }
    cout << fixed << setprecision(0) << ans << endl;
  }
  return 0;
}
