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 long int A[200005], S[30][200005], C[30][200005];
long long int n;
vector<long long int> ans;
bool parity = true;
void addition(vector<long long int> v) {
  for (int i = 0; i < v.size(); i++) {
    long long int temp = ans[i] + v[i];
    if (temp >= 10) {
      ans[i] = temp - 10;
      ans[i + 1]++;
    } else {
      ans[i] = temp;
    }
  }
}
void subtration(vector<long long int> v) {
  for (int i = 0; i < 30; i++) {
    long long int temp = ans[i] - v[i];
    if (temp < 0) {
      temp += 10;
      ans[i] = temp;
      v[i + 1]++;
    } else
      ans[i] = temp;
  }
}
bool greaterThan(vector<long long int> v1, vector<long long int> v2) {
  for (int i = 29; i >= 0; i--) {
    if (v1[i] > v2[i]) return true;
    if (v1[i] < v2[i]) return false;
  }
  return true;
}
void bigAns(long long int a) {
  if (a == 0) return;
  vector<long long int> v;
  bool posi = true;
  for (int i = 0; i < 30; i++) v.push_back(0LL);
  if (a < 0) {
    posi = false;
    a *= -1;
  }
  long long int id = 0;
  while (a) {
    long long int tut = a % 10;
    a /= 10;
    v[id] = tut;
    id++;
  }
  if (!greaterThan(ans, v)) {
    vector<long long int> tempV;
    tempV = ans;
    ans = v;
    v = tempV;
    swap(parity, posi);
  }
  if (parity != posi) {
    subtration(v);
  } else {
    addition(v);
  }
}
void build(long long int depth, long long int b, long long int e) {
  if (b == e) {
    S[depth][b] = A[b];
    C[depth][b] = A[b];
    return;
  }
  long long int mid = (b + e) / 2;
  build(depth + 1, b, mid);
  build(depth + 1, mid + 1, e);
  long long int _x = b, _y = mid + 1, _id = b;
  while (true) {
    if (_x >= mid + 1 && _y >= e + 1) break;
    if (_x >= mid + 1) {
      S[depth][_id] = S[depth + 1][_y];
      _id++, _y++;
    } else if (_y >= e + 1) {
      S[depth][_id] = S[depth + 1][_x];
      _id++, _x++;
    } else {
      if (S[depth + 1][_x] < S[depth + 1][_y]) {
        S[depth][_id] = S[depth + 1][_x];
        _id++, _x++;
      } else {
        S[depth][_id] = S[depth + 1][_y];
        _id++, _y++;
      }
    }
  }
  C[depth][b] = S[depth][b];
  for (long long int i = b + 1; i <= e; i++) {
    C[depth][i] = C[depth][i - 1] + S[depth][i];
  }
  return;
}
long long int query(long long int depth, long long int b, long long int e,
                    long long int x, long long int y, long long int val) {
  if (b > y || e < x) return 0;
  if (b >= x && e <= y) {
    long long int _bg = b, _ed = e, id = e + 1, ret = 0;
    while (_bg <= _ed) {
      long long int mid = (_bg + _ed) / 2;
      if (S[depth][mid] >= val + 2) {
        id = min(id, mid);
        _ed = mid - 1;
      } else
        _bg = mid + 1;
    }
    if (id < e + 1) {
      long long int temp = 0;
      if (id == b)
        temp = C[depth][e];
      else
        temp = C[depth][e] - C[depth][id - 1];
      ret += temp - val * (e - id + 1);
    }
    _bg = b, _ed = e, id = b - 1;
    while (_bg <= _ed) {
      long long int mid = (_bg + _ed) / 2;
      if (S[depth][mid] <= val - 2) {
        id = max(id, mid);
        _bg = mid + 1;
      } else
        _ed = mid - 1;
    }
    if (id != b - 1) {
      long long int temp = C[depth][id];
      ret += temp - val * (id - b + 1);
    }
    return ret;
  }
  long long int mid = (b + e) / 2;
  return query(depth + 1, b, mid, x, y, val) +
         query(depth + 1, mid + 1, e, x, y, val);
}
int main() {
  scanf("%I64d", &n);
  for (long long int i = 1; i <= n; i++) scanf("%I64d", &A[i]);
  build(1, 1, n);
  for (int i = 0; i < 30; i++) ans.push_back(0LL);
  for (long long int i = 1; i < n; i++) {
    bigAns(query(1, 1, n, i + 1, n, A[i]));
  }
  bool x = false, isZero = true;
  for (int i = 0; i < 30; i++)
    if (ans[i] != 0) isZero = false;
  if (isZero) {
    cout << 0 << endl;
    return 0;
  }
  if (!parity) cout << "-";
  for (int i = 29; i >= 0; i--) {
    if (ans[i] != 0) x = true;
    if (x) {
      cout << ans[i];
    }
  }
  cout << endl;
  return 0;
}
