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