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