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 Node {
  long long Value, ID;
};
Node Data[200010];
long double Sum[200010];
int ID[200010];
int N, Index = 0;
long double Ans = 0;
queue<int> Q;
bool cmp(Node A, Node B) {
  if (A.Value == B.Value) return A.ID < B.ID;
  return A.Value < B.Value;
}
long double Solve(int L, int R, int x) {
  if (L == -1 || R == -1) return 0;
  if (L == R) {
    if (x < Data[L].ID)
      return 1;
    else
      return -1;
  }
  if (x < Data[L].ID)
    return R - L + 1;
  else if (x > Data[R].ID)
    return -(R - L + 1);
  int tempL = L, tempR = R;
  int LastL = -1, LastR = -1;
  while (L < R) {
    if (L == LastL && R == LastR) break;
    LastL = L;
    LastR = R;
    int mid = (L + R) >> 1;
    if (Data[mid].ID <= x)
      L = mid;
    else if (Data[mid].ID > x)
      R = mid - 1;
  }
  if (L - 1 >= tempL && Data[L - 1].ID < x && x < Data[L].ID)
    return (tempR - (L - 1)) - ((L - 1) - (tempL - 1));
  if (L + 1 <= tempR && Data[L].ID < x && x < Data[L + 1].ID)
    return (tempR - L) - (L - (tempL - 1));
  if (L - 2 >= tempL && Data[L - 2].ID < x && x < Data[L - 1].ID)
    return (tempR - (L - 2)) - ((L - 2) - (tempL - 1));
  if (L + 2 <= tempR && Data[L + 1].ID < x && x < Data[L + 2].ID)
    return (tempR - (L + 2 - 1)) - (L + 1 - (tempL - 1));
  return 0;
}
long long SolveB(int L, int R, int x) {
  if (L == -1 || R == -1) return 0;
  if (L == R) {
    if (x < Data[L].ID)
      return 1;
    else
      return -1;
  }
  int pos;
  for (register int i = L; i < R; ++i) {
    if (Data[i].ID < x && Data[i + 1].ID > x) {
      pos = i;
      break;
    }
  }
  if (x < Data[L].ID)
    return R - L + 1;
  else if (x > Data[R].ID)
    return -(R - L + 1);
  return (R - (pos)) - (pos - (L - 1));
}
int main() {
  scanf("%d", &N);
  for (register int i = 1; i <= N; ++i) {
    scanf("%I64d", &Data[i].Value);
    Sum[i] = Sum[i - 1] + Data[i].Value;
    Data[i].ID = i;
    if (i != 1) Ans += (i - 1) * Data[i].Value - Sum[i - 1];
  }
  sort(Data + 1, Data + N + 1, cmp);
  int PreL = -1, PreR = -1, CurL = 1;
  for (register int i = 2; i <= N; ++i) {
    if (Data[i].Value != Data[i - 1].Value) {
      PreL = CurL;
      PreR = i - 1;
      CurL = i;
    }
    if (Data[PreL].Value == Data[i].Value - 1) {
      Ans += Solve(PreL, PreR, Data[i].ID);
    }
  }
  cout << fixed << setprecision(0) << Ans << endl;
  return 0;
}
