#include <bits/stdc++.h>
using namespace std;
long long n;
map<long long, long long> mp;
vector<long long> a;
void solve() {
  cin >> n;
  a.resize(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  long double ans = 0, sum = 0;
  for (long long i = n - 1; i >= 0; i--) {
    sum += a[i];
    ans += sum - (n - i) * a[i] - mp[a[i] + 1] + mp[a[i] - 1];
    mp[a[i]]++;
  }
  cout << fixed << setprecision(0);
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
