#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long ans1 = 0, ans = 0;
  long long int ck = 0, p, sum = 0, a;
  map<long long int, long long int> cnt;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p;
    a = (p * i) - sum - cnt[p - 1] + cnt[p + 1];
    if (a < 0) {
      a *= -1;
      ans1 += a;
    } else
      ans += a;
    sum += p;
    cnt[p]++;
  }
  if (ans1 > ans)
    cout << "-" << ans1 - ans << endl;
  else
    cout << ans - ans1 << endl;
  return 0;
}
