#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long double n, s = 0, d = 0, a;
  cin >> n;
  map<int, int> c;
  for (int i = 0; i < n; i++) {
    cin >> a;
    d += a * i - s + c[(int)a + 1] - c[(int)a - 1];
    s += a;
    c[(int)a]++;
  }
  cout << setprecision(0) << fixed << d << "\n";
}
