#include <bits/stdc++.h>
using namespace std;
long long a[1000001] = {0}, i, n;
int main() {
  long double sum = 0, ans = 0;
  map<long long, long long> m;
  cin >> n;
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) {
    ans += (i * a[i]) - sum + m[a[i] + 1] - m[a[i] - 1];
    m[a[i]]++;
    sum += a[i];
  }
  string k = to_string(ans);
  long long t = 0;
  while (k[t] != '.') cout << k[t++];
  return 0;
}
