#include <bits/stdc++.h>
using namespace std;
const int Tmax = 200005;
int n, p;
long long int sum, tmp;
map<long long int, int> MM;
long double ans;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &tmp);
    ans += (i - 1) * tmp - sum + MM[tmp + 1] - MM[tmp - 1];
    sum += tmp;
    MM[tmp]++;
  }
  cout << fixed << setprecision(0) << ans;
  return 0;
}
