#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a;
  map<long long, long long> make_pair;
  a.resize(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long double ans = 0, sum = 0;
  for (int i = n - 1; i >= 0; i--) {
    sum += a[i];
    ans += sum - (n - i) * a[i] - make_pair[a[i] + 1] + make_pair[a[i] - 1];
    make_pair[a[i]]++;
  }
  cout << fixed << setprecision(0);
  cout << ans;
}
