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 MOD = 1e9 + 7;
long long n = 1, n2, a[200010], sum[200010];
vector<long long> dat[800010];
struct stane {
  string val;
  bool isneg;
} ans;
void INIT(int k, int lb, int ub) {
  if (lb == ub) return;
  INIT(k * 2 + 1, lb, (lb + ub) / 2);
  INIT(k * 2 + 2, (lb + ub) / 2 + 1, ub);
  int i = 0, j = 0;
  while (i < dat[k * 2 + 1].size() || j < dat[k * 2 + 2].size()) {
    if (i == dat[k * 2 + 1].size())
      dat[k].push_back(dat[k * 2 + 2][j++]);
    else if (j == dat[k * 2 + 2].size())
      dat[k].push_back(dat[k * 2 + 1][i++]);
    else if (dat[k * 2 + 1][i] < dat[k * 2 + 2][j])
      dat[k].push_back(dat[k * 2 + 1][i++]);
    else
      dat[k].push_back(dat[k * 2 + 2][j++]);
  }
}
long long query(int k, int lb, int ub, int tlb, int tub, long long val) {
  if (tlb > tub || ub < tlb || tub < lb) return 0;
  if (tlb <= lb && ub <= tub)
    return lower_bound(dat[k].begin(), dat[k].end(), val + 1) -
           lower_bound(dat[k].begin(), dat[k].end(), val);
  return query(k * 2 + 1, lb, (lb + ub) / 2, tlb, tub, val) +
         query(k * 2 + 2, (lb + ub) / 2 + 1, ub, tlb, tub, val);
}
stane myitoa(long long x) {
  stane ret;
  ret.val = "";
  ret.isneg = (x < 0 ? true : false);
  x = abs(x);
  while (x > 0) {
    ret.val.push_back(x % 10 + '0');
    x /= 10;
  }
  if (ret.val.size() == 0) ret.val.push_back('0');
  return ret;
}
bool larger(string a, string b) {
  if (a.size() > b.size()) return true;
  if (b.size() > a.size()) return false;
  for (int i = a.size() - 1; i >= 0; i--)
    if (a[i] != b[i]) return a[i] > b[i];
  return false;
}
string realadd(string a, string b) {
  string ret = "";
  int jw = 0;
  while (b.size() < a.size()) b.push_back('0');
  for (int i = 0; i < a.size(); i++) {
    ret.push_back((a[i] + b[i] - '0' - '0' + jw) % 10 + '0');
    jw = (a[i] + b[i] - '0' - '0' + jw) / 10;
  }
  if (jw > 0) ret.push_back(jw + '0');
  return ret;
}
string minu(string a, string b) {
  string ret = "";
  int tw = 0;
  while (b.size() < a.size()) b.push_back('0');
  for (int i = 0; i < b.size(); i++) {
    if (a[i] + '0' - b[i] - tw < '0') {
      ret.push_back(a[i] + 10 - b[i] - tw + '0');
      tw = 1;
    } else {
      ret.push_back(a[i] - b[i] - tw + '0');
      tw = 0;
    }
  }
  while (ret[ret.size() - 1] == '0') ret.pop_back();
  return ret;
}
stane add(stane a, stane b) {
  if (larger(b.val, a.val)) {
    swap(a.val, b.val);
    swap(a.isneg, b.isneg);
  }
  stane ret;
  if (a.isneg == b.isneg) {
    ret.isneg = a.isneg;
    ret.val = realadd(a.val, b.val);
  } else if (a.isneg) {
    ret.isneg = true;
    ret.val = minu(a.val, b.val);
  } else {
    ret.isneg = false;
    ret.val = minu(a.val, b.val);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n2;
  while (n < n2) n *= 2;
  for (int i = 0; i < n2; i++) {
    cin >> a[i];
    dat[i + n - 1].push_back(a[i]);
  }
  INIT(0, 0, n - 1);
  for (int i = n2 - 1; i >= 0; i--) sum[i] = sum[i + 1] + a[i];
  ans.val = "0";
  ans.isneg = false;
  for (int i = 0; i < n2 - 1; i++) {
    long long numa = query(0, 0, n - 1, i + 1, n2 - 1, a[i] - 1),
              numb = query(0, 0, n - 1, i + 1, n2 - 1, a[i]),
              numc = query(0, 0, n - 1, i + 1, n2 - 1, a[i] + 1);
    ans = add(ans, myitoa(sum[i + 1] - numa * (a[i] - 1) - numb * a[i] -
                          numc * (a[i] + 1) -
                          a[i] * (n2 - i - 1 - numa - numb - numc)));
  }
  reverse(ans.val.begin(), ans.val.end());
  if (ans.val.size() == 0) {
    ans.val.push_back('0');
    ans.isneg = false;
  }
  cout << (ans.isneg ? "-" : "") << ans.val << endl;
  return 0;
}
