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 double ans = 0;
void Merge(vector<long double> &v) {
  if (v.size() <= 1) return;
  int ind = 0;
  vector<long double> x, y;
  for (ind = 0; ind < v.size() / 2; ind++) x.push_back(v[ind]);
  for (; ind < v.size(); ind++) y.push_back(v[ind]);
  Merge(x);
  Merge(y);
  vector<long double> px(x.size()), py(y.size());
  px[px.size() - 1] = x[px.size() - 1];
  py[py.size() - 1] = y[py.size() - 1];
  for (int i = px.size() - 2; i >= 0; i--) px[i] = px[i + 1] + x[i];
  for (int i = py.size() - 2; i >= 0; i--) py[i] = py[i + 1] + y[i];
  vector<long double>::iterator xt = x.begin(), yt = y.begin();
  long double sum = 0;
  while (1) {
    if (xt == x.end() || yt == y.end()) break;
    if (*xt < *yt) {
      int r = upper_bound(y.begin(), y.end(), *xt + 1) - y.begin();
      if (r != y.size()) sum += py[r] - (y.size() - r) * (*xt);
      ++xt;
    } else {
      int r = upper_bound(x.begin(), x.end(), *yt + 1) - x.begin();
      if (r != x.size()) sum += (x.size() - r) * (*yt) - px[r];
      ++yt;
    }
  }
  ans += sum;
  merge(x.begin(), x.end(), y.begin(), y.end(), v.begin());
}
int main() {
  int n;
  cin >> n;
  vector<long double> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  Merge(a);
  cout << fixed << setprecision(0) << ans << "\n";
}
