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>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
using llong = long long;
using ld = long double;
using ii = pair<int, int>;
using ull = unsigned long long;
using pll = pair<llong, llong>;
using psi = pair<string, int>;
using ll = pair<llong, llong>;
const llong over999 = 1e9;
const ld over999ld = 1e16;
const llong md = 1e9 + 7;
const ld eps = 1e-9;
const ld Pi = acos(-1);
const llong nich = 0;
const ld mnogo = 2e14;
const int base = 1e9;
const llong MX = 1e9 + 1;
unordered_map<llong, llong> t, t2, m;
llong x, n, sum;
ld ans;
bool isBigger(string a, string b) {
  if (a.size() > b.size())
    return true;
  else if (b.size() > a.size())
    return false;
  return (a > b);
}
string dlink(string s1, string s2) {
  vector<int> a, b;
  int minus = 0;
  if (s1[0] == '-') {
    minus++;
    s1.erase(s1.begin());
  }
  if (s2[0] == '-') {
    minus += 3;
    s2.erase(s2.begin());
  }
  for (int i = (int)s1.length(); i > 0; i -= 9)
    if (i < 9)
      a.push_back(atoi(s1.substr(0, i).c_str()));
    else
      a.push_back(atoi(s1.substr(i - 9, 9).c_str()));
  for (int i = (int)s2.length(); i > 0; i -= 9)
    if (i < 9)
      b.push_back(atoi(s2.substr(0, i).c_str()));
    else
      b.push_back(atoi(s2.substr(i - 9, 9).c_str()));
  if (minus % 2 != 0) {
    if (minus == 1) {
      if (isBigger(s1, s2)) {
      } else {
        minus = 0;
        swap(a, b);
      }
    } else {
      if (isBigger(s2, s1)) {
        minus = 1;
        swap(a, b);
      }
    }
    int carry = 0;
    for (size_t i = 0; i < b.size() || carry; ++i) {
      a[i] -= carry + (i < b.size() ? b[i] : 0);
      carry = a[i] < 0;
      if (carry) a[i] += base;
    }
    while (a.size() > 1 && a.back() == 0) a.pop_back();
  } else {
    int carry = 0;
    for (size_t i = 0; i < max(a.size(), b.size()) || carry; ++i) {
      if (i == a.size()) a.push_back(0);
      a[i] += carry + (i < b.size() ? b[i] : 0);
      carry = a[i] >= base;
      if (carry) a[i] -= base;
    }
  }
  string tmp = "";
  if (a.empty()) {
    return "0";
  } else
    tmp += to_string(a.back());
  for (int i = (int)a.size() - 2; i >= 0; --i) {
    string gg = to_string(a[i]);
    while (gg.size() < 9) gg = "0" + gg;
    tmp = tmp + gg;
  }
  if (minus == 1 || minus == 4)
    return "-" + tmp;
  else
    return tmp;
}
void inc_1(int i, llong x) {
  for (; i <= MX; i = (i | (i + 1))) t[i] += x;
}
void inc_2(int i, llong x) {
  for (; i <= MX; i = (i | (i + 1))) t2[i] += x;
}
llong sum_1(int r) {
  llong result = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) result += t[r];
  return result;
}
llong sum_2(int r) {
  llong result = 0;
  for (; r >= 0; r = (r & (r + 1)) - 1) result += t2[r];
  return result;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    m[x]++;
    sum += x;
    ans += (x * (i - m[x] - m[x - 1] - m[x + 1]) -
            (sum - m[x] * x - m[x - 1] * (x - 1) - m[x + 1] * (x + 1)));
  }
  cout << fixed << setprecision(0);
  cout << ans << endl;
  return 0;
}
