#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 1;
const int mod = 1e9 + 7;
void slv() {
  int64_t n;
  cin >> n;
  map<int64_t, int64_t> a;
  long double ans = 0, sum = 0;
  for (int64_t i = 0; i < n; i++) {
    int64_t t;
    cin >> t;
    sum += t;
    ++a[t];
    ans += (i - a[t] - a[t - 1] - a[t + 1] + 1) * t -
           (sum - a[t] * t - a[t - 1] * (t - 1) - a[t + 1] * (t + 1));
  }
  cout << fixed << setprecision(0) << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    slv();
    cout << '\n';
  }
  return 0;
}
