#include <bits/stdc++.h>
using namespace std;
using ll = long double;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n;
  cin >> n;
  map<ll, ll> mp;
  ll sum = 0;
  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    ll x;
    cin >> x;
    sum += x;
    mp[x]++;
    ll a = mp[x - 1];
    ll b = mp[x];
    ll c = mp[x + 1];
    ans += x * (i - (a + b + c));
    ans -= (sum - a * (x - 1) - b * x - c * (x + 1));
  }
  cout << fixed << setprecision(0) << ans << "\n";
  return 0;
}
