#include <bits/stdc++.h>
using namespace std;
const long double NMAX = 200001;
const long double INF = (1 << 30);
const long double MOD = 1000000007;
const long double BLOCK = 101;
const long double nr_of_bits = 17;
map<long double, long double> mp;
int main() {
  long double rez = 0, i, n, sum = 0, cnt = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    long double x;
    cin >> x;
    sum += x;
    mp[x]++;
    rez = sum;
    rez -= (mp[x] * x + mp[x - 1] * (x - 1) + mp[x + 1] * (x + 1));
    rez = 0 - rez;
    rez += x * (i - mp[x] - mp[x - 1] - mp[x + 1]);
    cnt += rez;
  }
  cout << fixed << setprecision(0) << cnt;
  return 0;
}
