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;
struct BIGNUM {
  int cnt;
  int wfSign;
  int dig[200];
};
void chengfa(BIGNUM &x, BIGNUM &y, BIGNUM &z) {
  int i, j;
  int s = x.cnt + y.cnt + 1;
  if (s >= 200) {
    s = 199;
  }
  for (i = 0; i <= s; i++) {
    z.dig[i] = 0;
  }
  for (i = 0; i < x.cnt; i++) {
    for (j = 0; j < y.cnt; j++) {
      z.dig[i + j] += x.dig[i] * y.dig[j];
    }
  }
  for (i = 0; i <= s; i++) {
    z.dig[i + 1] += z.dig[i] / 10000;
    z.dig[i] %= 10000;
  }
  i = s;
  while (z.dig[i] == 0) {
    i--;
  }
  z.cnt = i + 1;
  z.wfSign = x.wfSign * y.wfSign;
}
bool isBigger(BIGNUM &x, BIGNUM &y) {
  if (x.cnt > y.cnt) {
    return 1;
  } else if (x.cnt < y.cnt) {
    return 0;
  }
  int i;
  for (i = x.cnt - 1; i >= 0; i--) {
    if (x.dig[i] > y.dig[i]) {
      return true;
    } else if (x.dig[i] < y.dig[i]) {
      return false;
    }
  }
  return false;
}
void showRes(BIGNUM &rs) {
  if (rs.wfSign == -1) {
    printf("-");
  }
  printf("%d", rs.dig[rs.cnt - 1]);
  int i;
  for (i = rs.cnt - 2; i >= 0; i--) {
    printf("%04d", rs.dig[i]);
  }
  printf("\n");
}
void jiafa(BIGNUM &x, BIGNUM &y) {
  if (x.wfSign == -1 && y.wfSign == -1) {
    x.wfSign = 1;
    y.wfSign = 1;
    jiafa(x, y);
    x.wfSign = -1;
    return;
  }
  if (x.wfSign * y.wfSign == -1) {
    bool f = isBigger(x, y);
    if (f && x.wfSign == -1) {
      x.wfSign = 1;
      y.wfSign = -1;
      jiafa(x, y);
      x.wfSign = -1;
      return;
    } else if (!f && y.wfSign == -1) {
      x.wfSign = -1;
      y.wfSign = 1;
      jiafa(x, y);
      x.wfSign = -1;
      return;
    }
  }
  int s = x.cnt < y.cnt ? x.cnt : y.cnt;
  int i;
  for (i = 0; i < s; i++) {
    x.dig[i] = x.dig[i] * x.wfSign + y.dig[i] * y.wfSign;
  }
  while (i < y.cnt) {
    x.dig[i] = y.wfSign * y.dig[i];
    i++;
  }
  s = x.cnt > y.cnt ? x.cnt : y.cnt;
  x.dig[s] = 0;
  for (i = 0; i < s; i++) {
    if (x.dig[i] < 0) {
      x.dig[i] += 10000;
      x.dig[i + 1]--;
    } else {
      x.dig[i + 1] += x.dig[i] / 10000;
      x.dig[i] %= 10000;
    }
  }
  i = s;
  while (i > 0 && x.dig[i] == 0) {
    i--;
  }
  x.cnt = i + 1;
  x.wfSign = 1;
}
void init(BIGNUM &x, int val) {
  int i = 0;
  x.dig[0] = 0;
  if (val < 0) {
    x.wfSign = -1;
    val *= -1;
  } else {
    x.wfSign = 1;
  }
  while (val) {
    x.dig[i] = val % 10000;
    val /= 10000;
    i++;
  }
  if (i == 0) {
    i = 1;
  }
  x.cnt = i;
}
int n, m;
int a[2340000], b[2340000], c[2340000];
int wf(int val) {
  int x = 0;
  int y = m - 1;
  int mid;
  while (x < y) {
    mid = (x + y) / 2;
    if (b[mid] == val) {
      x = mid;
      break;
    } else if (val > b[mid]) {
      x = mid + 1;
    } else {
      y = mid;
    }
  }
  c[x]++;
  int rt = 0;
  if (x > 0) {
    if (b[x - 1] == val - 1) {
      rt += c[x - 1];
    }
  }
  if (x < n - 1) {
    if (b[x + 1] == val + 1) {
      rt -= c[x + 1];
    }
  }
  return rt;
}
void solve() {
  int i, j;
  BIGNUM x, y, z, rs;
  rs.wfSign = 1;
  rs.cnt = 1;
  rs.dig[0] = 0;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[i] = a[i];
    init(x, i - n + i + 1);
    init(y, a[i]);
    chengfa(x, y, z);
    jiafa(rs, z);
  }
  sort(b, b + n);
  m = 1;
  for (j = 1; j < n; j++) {
    if (b[j] != b[j - 1]) {
      b[m++] = b[j];
    }
  }
  for (i = 0; i < m; i++) {
    c[i] = 0;
  }
  for (i = n - 1; i >= 0; i--) {
    int v = wf(a[i]);
    init(z, v);
    jiafa(rs, z);
  }
  showRes(rs);
}
int main() {
  while (scanf("%d", &n) != EOF) {
    solve();
  }
  return 0;
}
