#include <bits/stdc++.h>
using namespace std;
int n;
int a[200005];
long long sum;
map<int, int> cnt;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long double res = 0;
  for (int i = 0; i < n; ++i) {
    cnt[a[i]]++;
    sum += a[i];
    int c = cnt[a[i]];
    long long cur = sum - cnt[a[i]] * 1ll * a[i];
    if (cnt.count(a[i] - 1)) {
      cur -= cnt[a[i] - 1] * 1ll * (a[i] - 1);
      c += cnt[a[i] - 1];
    }
    if (cnt.count(a[i] + 1)) {
      cur -= cnt[a[i] + 1] * 1ll * (a[i] + 1);
      c += cnt[a[i] + 1];
    }
    res += (i - c + 1) * 1ll * a[i] - cur;
  }
  cout.precision(0);
  cout << fixed << res << endl;
  return 0;
}
