#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, MOD = 1e9 + 7, MAXN = 1e5 + 10;
const long double inf = 1e10 + 10;
long double a[N];
map<long double, long double> m;
int main() {
  int n;
  cin >> n;
  long double sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  long double ans = 0;
  sum += a[n];
  m[a[n]]++;
  int j = 1;
  for (int i = n - 1; i > 0; i--) {
    long double cnt = sum;
    cnt -= m[a[i]] * a[i];
    cnt -= m[a[i] + 1] * (a[i] + 1);
    cnt -= m[a[i] - 1] * (a[i] - 1);
    long double tmp = m[a[i]] + m[a[i] + 1] + m[a[i] - 1];
    ans += cnt - (j - tmp) * a[i];
    sum += a[i];
    m[a[i]]++;
    j++;
  }
  cout << fixed << setprecision(0) << ans << endl;
  return 0;
}
