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