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 MX = 250;
void sum(string &a, string &b) {
  long long d = 0;
  for (long long i = 0; i < (MX); i++) {
    long long sm = (long long)(a[i]) + b[i] + d - 2ll * '0';
    d = sm >= 10;
    sm -= d * 10;
    a[i] = '0' + (char)(sm);
  }
}
void diff(string &a, string &b) {
  for (long long i = 0; i < (MX); i++) {
    if (a[i] < b[i]) {
      long long j = i + 1;
      while (a[j] == '0') j++;
      a[j]--;
      j--;
      while (j != i) a[j] = '9', j--;
      a[i] += 10 - (b[i] - '0');
    } else {
      a[i] -= b[i] - '0';
    }
  }
}
void Solve() {
  long long n;
  cin >> n;
  vector<long long> a(n), pr(n + 1);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  for (long long i = n - 1; i >= 0; --i) pr[i] = pr[i + 1] + a[i];
  map<long long, long long> cnt;
  for (long long i = 0; i < (n); i++) {
    cnt[a[i]]++;
  }
  vector<long long> ans(n);
  for (long long i = 0; i < (n); i++) {
    cnt[a[i]]--;
    long long cnt1 = cnt[a[i] - 1];
    long long cnt2 = cnt[a[i]];
    long long cnt3 = cnt[a[i] + 1];
    ans[i] = (pr[i + 1] - cnt1 * (a[i] - 1) - cnt2 * a[i] - cnt3 * (a[i] + 1)) -
             (n - i - 1 - cnt1 - cnt2 - cnt3) * a[i];
  }
  string z1, z2;
  for (long long i = 0; i < (MX); i++) z1 += "0";
  for (long long i = 0; i < (MX); i++) z2 += "0";
  for (long long i = 0; i < n; ++i) {
    if (ans[i] > 0) {
      string b = to_string(ans[i]);
      reverse((b).begin(), (b).end());
      while (b.length() < MX) b += "0";
      sum(z1, b);
    }
    if (ans[i] < 0) {
      string b = to_string(-ans[i]);
      reverse((b).begin(), (b).end());
      while (b.length() < MX) b += "0";
      sum(z2, b);
    }
  }
  reverse((z1).begin(), (z1).end());
  reverse((z2).begin(), (z2).end());
  if (z2 > z1) {
    cout << '-';
    swap(z1, z2);
  }
  reverse((z1).begin(), (z1).end());
  reverse((z2).begin(), (z2).end());
  diff(z1, z2);
  long long i = 0;
  reverse((z1).begin(), (z1).end());
  while (i < z1.length() && z1[i] == '0') i++;
  if (i == z1.length())
    cout << 0;
  else {
    while (i < z1.length()) {
      cout << z1[i++];
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  Solve();
  return 0;
}
