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 N = 2e5 + 1;
long long bit[N] = {0}, pos[N], bit2[N] = {0};
void add(long long p, long long val) {
  for (; p < N; p += p & (-p)) bit[p] += val;
}
long long query(long long p) {
  long long res = 0;
  for (; p > 0; p -= p & (-p)) res += bit[p];
  return res;
}
void add2(long long p, long long val) {
  for (; p < N; p += p & (-p)) bit2[p] += val;
}
long long query2(long long p) {
  long long res = 0;
  for (; p > 0; p -= p & (-p)) res += bit2[p];
  return res;
}
void compress(vector<long long> a) {
  vector<pair<long long, long long> > v;
  for (long long i = 0; i < a.size(); i++) {
    v.push_back({a[i], i});
  }
  sort(v.begin(), v.end());
  for (long long i = 0; i < v.size(); i++) {
    pos[v[i].second] = i + 1;
    add(i + 1, v[i].first);
  }
}
signed main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  compress(a);
  multiset<pair<long long, long long> > s, s2;
  for (long long i = 0; i < n; i++) {
    s.insert({a[i], i});
  }
  long double ans = 0;
  for (long long i = 0; i < n; i++) {
    s.erase(s.find({a[i], i}));
    add(pos[i], -a[i]);
    auto it = s.lower_bound({a[i] + 2, 0});
    if (it != s.end()) {
      ans += query(n) - query(pos[it->second] - 1);
    }
    it = s.lower_bound({a[i] - 1, 0});
    if (it != s.begin()) {
      --it;
      ans += query(pos[it->second]);
    } else if (it->first == a[i] - 2) {
      ans += it->first;
    }
    it = s2.lower_bound({a[i] + 2, 0});
    if (it != s2.end()) {
      ans = ans - (query2(n) - query2(pos[it->second] - 1));
    }
    it = s2.lower_bound({a[i] - 1, 0});
    if (it != s2.begin()) {
      --it;
      ans = ans - query2(pos[it->second]);
    } else if (it->first == a[i] - 2)
      ans = ans - it->first;
    s2.insert({a[i], i});
    add2(pos[i], a[i]);
  }
  if (ans >= 0)
    cout << (unsigned long long)ans;
  else {
    ans = fabs(ans);
    cout << "-" << (unsigned long long)ans;
  }
  return 0;
}
