#include <bits/stdc++.h>
using namespace std;
int i, j, k, l, n, m;
long double ans, x;
map<int, long double> Map;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    cin >> x;
    ans += (long double)((i + i - n - 1) * x + Map[x + 1] - Map[x - 1]);
    Map[x]++;
  }
  cout << fixed << setprecision(0) << ans;
}
