#include <bits/stdc++.h>
using namespace std;
long long a[200005];
map<long long, int> mp;
int main() {
  int n;
  cin >> n;
  long double ans = 0, sum = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    ans += (i - 1) * a[i] - sum + mp[a[i] + 1] - mp[a[i] - 1];
    mp[a[i]]++;
    sum += a[i];
  }
  cout << fixed << setprecision(0) << ans << endl;
}
