#include <bits/stdc++.h>
using namespace std;
ifstream f("A.in");
ofstream g("A.out");
int t, T;
const int dim = 2e5 + 10;
long double n, a[dim], s[dim], ans;
unordered_map<long double, int> H;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    s[i] = s[i - 1] + a[i];
  }
  for (int i = 1; i <= n; i++) {
    ans = ans + ((i - 1) * a[i] - s[i - 1]) - H[a[i] - 1] + H[a[i] + 1];
    H[a[i]]++;
  }
  cout << fixed << setprecision(0) << ans;
  return 0;
}
