#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  long double ans = 0;
  long double a[n + 1];
  map<long double, long double> mp;
  long double sum = 0;
  cout << fixed;
  cout << setprecision(0);
  for (int i = 1; i < n + 1; i++) {
    cin >> a[i];
    mp[a[i]]++;
    long double cp = 0;
    long double cs = 0;
    if (mp.find(a[i] - 1) != mp.end()) cp = mp[a[i] - 1];
    if (mp.find(a[i] + 1) != mp.end()) cs = mp[a[i] + 1];
    long double prev = i - 1;
    prev = prev - cp - cs;
    long double prev_sum = sum - (cp * (a[i] - 1)) - (cs * (a[i] + 1));
    ans = ans + (a[i] * prev) - prev_sum;
    sum = sum + a[i];
  }
  cout << ans << '\n';
  return 0;
}
