#include <bits/stdc++.h>
using namespace std;
map<long double, int> cant;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<long double> A(n + 1);
  for (int i = (1); i < (n + 1); i++) cin >> A[i];
  vector<long double> prefixSum(n + 2);
  prefixSum[0] = 0;
  for (int i = (1); i < (n + 2); i++) {
    prefixSum[i] = prefixSum[i - 1] + A[i];
  }
  long double total = 0;
  for (int i = (1); i < (n + 1); i++) {
    long double prim = prefixSum[i - 1] - A[i] * (i - 1);
    long double sec = A[i] * cant[A[i] - 1.] - (A[i] - 1.) * cant[A[i] - 1.];
    long double tri = A[i] * cant[A[i] + 1.] - (A[i] + 1.) * cant[A[i] + 1.];
    total -= (prim + sec + tri);
    cant[A[i]]++;
  }
  cout << fixed << setprecision(0) << total << "\n";
}
