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;
using INT = long long;
int a[600100], arr[600100], cnt[600100];
INT b[600100];
void update(int u, int x) {
  for (; u < 600100; u += u & -u) b[u] += x, cnt[u]++;
}
INT CALC(int u, INT ans = 0) {
  for (; u; u -= u & -u) ans += b[u];
  return ans;
}
int calc(int u, int ans = 0) {
  for (; u; u -= u & -u) ans += cnt[u];
  return ans;
}
int main() {
  int n, nn = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    arr[++nn] = a[i];
    arr[++nn] = a[i] - 1;
    arr[++nn] = a[i] + 1;
  }
  sort(arr + 1, arr + nn + 1);
  nn = unique(arr + 1, arr + nn + 1) - arr - 1;
  INT ans = 0;
  int t = 0;
  for (int i = 1; i <= n; i++) {
    int id = lower_bound(arr + 1, arr + nn + 1, a[i]) - arr;
    INT tmp = 0;
    if (id > 2) {
      tmp += 1LL * a[i] * calc(id - 2);
      tmp -= CALC(id - 2);
    }
    tmp += 1LL * a[i] * (calc(600100 - 1) - calc(id + 1));
    tmp -= CALC(600100 - 1) - CALC(id + 1);
    ans += tmp;
    update(id, a[i]);
    if (ans >= 1000000000000000000)
      ans -= 1000000000000000000, t++;
    else if (ans < 0)
      ans += 1000000000000000000, t--;
  }
  if (t > 0) {
    printf("%d%.18I64d\n", t, ans);
    return 0;
  }
  if (t < 0) {
    t++;
    ans = 1000000000000000000 - ans;
    if (t)
      printf("%d%.18I64d\n", t, ans);
    else
      cout << -ans << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}
