#include <bits/stdc++.h>
using namespace std;
struct i128 {
  static const long long INF = 1e18;
  long long h, l;
  i128() {}
  i128(long long _h, long long _l) : h(_h), l(_l) {
    if (l >= INF || (h < 0 && l > 0)) {
      l -= INF;
      h++;
    } else if (l <= -INF || (h > 0 && l < 0)) {
      l += INF;
      h--;
    }
  }
  i128 operator+(const i128 b) { return i128(h + b.h, l + b.l); }
  i128 operator-(const i128 b) { return i128(h - b.h, l - b.l); }
  void out() {
    if (h == 0)
      printf("%lld", l);
    else
      printf("%lld%018lld", h, abs(l));
  }
};
const int N = 2e5 + 7;
int n;
void solve() {
  map<int, int> M;
  i128 ans(0, 0);
  for (int i = (1); i < (n + 1); ++i) {
    int a;
    scanf("%d", &a);
    ans = ans + i128(0, (2ll * i - n - 1) * a);
    if (M.count(a - 1)) ans = ans - i128(0, M[a - 1]);
    if (M.count(a + 1)) ans = ans + i128(0, M[a + 1]);
    M[a]++;
  }
  ans.out();
  puts("");
}
int main() {
  while (~scanf("%d", &n)) solve();
  return 0;
}
