#include <bits/stdc++.h>
using namespace std;
const long long MD = 1000000000000000000;
int main() {
  int n;
  cin >> n;
  long long ans = 0, sum = 0;
  long long carry = 0;
  unordered_map<int, int> mp;
  for (int j = 0; j < n; j++) {
    int a;
    cin >> a;
    ans += (long long)a * j - sum;
    ans -= mp[a - 1];
    ans += mp[a + 1];
    if (abs(ans) >= MD) {
      carry += ans / MD;
      ans %= MD;
    }
    mp[a]++;
    sum += a;
  }
  if (carry > 0 && ans < 0) {
    carry--;
    ans += MD;
  } else if (carry < 0 && ans > 0) {
    carry++;
    ans -= MD;
  }
  if (carry == 0)
    printf("%lld\n", ans);
  else {
    if (carry < 0) {
      carry = -carry;
      ans = -ans;
      printf("-");
    }
    printf("%lld%.18lld\n", carry, ans);
  }
  return 0;
}
