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