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 optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int __BS = 4096;
static char __bur[__BS + 16], *__er = __bur + __BS, *__ir = __er;
template <class T = int>
T readInt() {
  auto c = [&]() {
    if (__ir == __er)
      std::fill(__bur, __bur + __BS, 0), cin.read(__bur, __BS), __ir = __bur;
  };
  c();
  while (*__ir && (*__ir < '0' || *__ir > '9') && *__ir != '-') ++__ir;
  c();
  bool m = false;
  if (*__ir == '-') ++__ir, c(), m = true;
  T r = 0;
  while (*__ir >= '0' && *__ir <= '9') r = r * 10 + *__ir - '0', ++__ir, c();
  ++__ir;
  return m ? -r : r;
}
static char __buw[__BS + 20], *__iw = __buw, *__ew = __buw + __BS;
template <class T>
void writeInt(T x, char endc = '\n') {
  if (x < 0) *__iw++ = '-', x = -x;
  if (x == 0) *__iw++ = '0';
  char *s = __iw;
  while (x) {
    T t = x / 10;
    char c = x - 10 * t + '0';
    *__iw++ = c;
    x = t;
  }
  char *f = __iw - 1;
  while (s < f) swap(*s, *f), ++s, --f;
  if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  *__iw++ = endc;
}
template <class T>
void writeStr(const T &str) {
  int i = 0;
  while (str[i]) {
    *__iw++ = str[i++];
    if (__iw > __ew) cout.write(__buw, __iw - __buw), __iw = __buw;
  }
}
struct __FL__ {
  ~__FL__() {
    if (__iw != __buw) cout.write(__buw, __iw - __buw);
  }
};
static __FL__ __flushVar__;
template <class X, class Y>
void minimize(X &a, const Y &b) {
  a = (b < a) ? b : a;
}
template <class X, class Y>
void maximize(X &a, const Y &b) {
  a = (b > a) ? b : a;
}
const int M = 1000000000;
const int MN = 200000 + 10;
struct re {
  int x, y;
};
bool cmpx(re a, re b) { return a.x < b.x; }
int n, bit[MN];
long long b[MN];
re a[MN];
int get(int x) {
  int res = 0;
  while (x > 0) {
    res += bit[x];
    x -= x & -x;
  }
  return res;
}
void upd(int x, int g) {
  while (x <= n) {
    bit[x] += g;
    x += x & -x;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = (1); (i <= (n)); ++i) {
    cin >> a[i].x;
    a[i].y = i;
    b[i] = a[i].x;
  }
  sort(a + 1, a + 1 + n, cmpx);
  int j = 1, k = 1;
  long long tmp = 0;
  for (int i = (1); (i <= (n)); ++i) {
    while (a[j].x <= a[i].x - 1) {
      upd(a[j].y, 1);
      j++;
    }
    while (a[k].x < a[i].x - 1) {
      upd(a[k].y, -1);
      k++;
    }
    tmp -= get(a[i].y);
    tmp += j - k - get(a[i].y);
  }
  unsigned long long res;
  long long sign;
  if (tmp >= 0)
    res = tmp, sign = 1;
  else
    res = -tmp, sign = -1;
  for (int i = (1); (i <= (n)); ++i) {
    tmp = sign * b[i] * (i - 1 - n + i);
    if (tmp >= 0 || res >= -tmp)
      res += tmp;
    else {
      res = -tmp - 1LL * res;
      sign = -sign;
    }
  }
  if (sign == -1 && res != 0) cout << "-";
  cout << res;
}
