#include <bits/stdc++.h>
using namespace std;
long double a[2000002], b[2000002];
map<long long, long long> mp;
int main() {
  int n;
  cin >> n;
  long double sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = b[i - 1] + a[i];
    mp[a[i]]++;
    long double x = a[i] - 1;
    int y = a[i];
    int z = a[i] + 1;
    if (i != 1)
      sum = sum + y * (i - mp[x] - mp[y] - mp[z]) -
            (b[i - 1] - x * mp[x] - y * (mp[y] - 1) - z * mp[z]);
  }
  cout << fixed << setprecision(0) << sum << endl;
}
