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 int maxn = 200010;
vector<int> as;
long long bit_v[maxn * 3], bit_cnt[maxn * 3];
int a[maxn];
inline int lowbit(int x) { return x & -x; }
inline void modify(int pos, int v, long long* bit) {
  for (int i = pos; i <= (int)as.size(); i += lowbit(i)) bit[i] += v;
}
inline long long query(int pos, long long* bit) {
  long long sum = 0;
  for (int i = pos; i > 0; i -= lowbit(i)) sum += bit[i];
  return sum;
}
inline long long get_sum(int l, int r, long long* bit) {
  if (l > r) return 0;
  return query(r, bit) - query(l - 1, bit);
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    as.push_back(a[i] - 1);
    as.push_back(a[i]);
    as.push_back(a[i] + 1);
  }
  sort(as.begin(), as.end());
  as.erase(unique(as.begin(), as.end()), as.end());
  long long ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++) {
    int cur_pos = lower_bound(as.begin(), as.end(), a[i]) - as.begin() + 1;
    int a_1 = lower_bound(as.begin(), as.end(), a[i] - 1) - as.begin() + 1;
    ans2 += (get_sum(1, a_1, bit_cnt) - get_sum(a_1, a_1, bit_cnt)) * a[i] -
            (get_sum(1, a_1, bit_v) - get_sum(a_1, a_1, bit_v));
    ans1 += ans2 / 10000000000000000ll;
    ans2 %= 10000000000000000ll;
    a_1 = lower_bound(as.begin(), as.end(), a[i] + 1) - as.begin() + 1;
    ans2 +=
        (get_sum(a_1, (int)as.size(), bit_cnt) - get_sum(a_1, a_1, bit_cnt)) *
            a[i] -
        (get_sum(a_1, (int)as.size(), bit_v) - get_sum(a_1, a_1, bit_v));
    ans1 += ans2 / 10000000000000000ll;
    ans2 %= 10000000000000000ll;
    modify(cur_pos, a[i], bit_v);
    modify(cur_pos, 1, bit_cnt);
  }
  if (ans1) {
    if (ans1 && ans2 && (ans1 < 0) != (ans2 < 0)) {
      if (ans1 < 0)
        ans1++, ans2 = 10000000000000000ll - ans2;
      else
        ans1--, ans2 = 10000000000000000ll + ans2;
    }
    if (ans2 == 0) {
      printf("%lld0000000000000000\n", ans1);
    } else
      printf("%lld%lld\n", ans1, abs(ans2));
  } else
    printf("%lld\n", ans2);
  return 0;
}
