#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n;
map<int, int> mp;
long double a[N], sum[N];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%Lf", &a[i]);
    mp[a[i]]++;
  }
  for (int i = n - 1; i >= 0; --i) {
    sum[i] = sum[i + 1] + a[i];
  }
  long double ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += sum[i] - (mp[a[i] + 1] * (a[i] + 1) + mp[a[i] - 1] * (a[i] - 1) +
                     mp[a[i]] * (a[i]));
    int cnt = mp[a[i]] + mp[a[i] + 1] + mp[a[i] - 1];
    ans -= ((n - i - cnt) * a[i]);
    mp[a[i]]--;
  }
  printf("%.0Lf", ans);
}
