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