#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long n;
  scanf("%llu", &n);
  unsigned long long i, j, k, ans = 0, add = 0, sub = 0;
  map<unsigned long long, unsigned long long> cnt, sm, bi;
  unsigned long long num[n], sum[n], aneg = 0, neg = 0;
  scanf("%llu", &num[0]);
  sum[0] = num[0];
  cnt[num[0]] = 1;
  sm[num[0]] = 0;
  bi[num[0]] = 0;
  for (i = 1; i < n; i++) {
    scanf("%llu", &num[i]);
    sum[i] = sum[i - 1] + num[i];
    if (cnt.find(num[i]) == cnt.end()) cnt[num[i]] = 0;
    cnt[num[i]]++;
    if (cnt.find(num[i] - 1) == cnt.end())
      sm[i] = 0;
    else
      sm[i] = cnt[num[i] - 1];
    if (cnt.find(num[i] + 1) == cnt.end())
      bi[i] = 0;
    else
      bi[i] = cnt[num[i] + 1];
  }
  for (i = 1; i < n; i++) {
    add = num[i] * i + bi[i];
    sub = sm[i] + sum[i - 1];
    if (add >= sub) {
      k = add - sub;
      neg = 0;
    } else {
      k = sub - add;
      neg = 1;
    }
    if (aneg == 0) {
      if (neg == 0)
        ans = ans + k;
      else if (k > ans) {
        ans = k - ans;
        aneg = 1;
      } else
        ans = ans - k;
    } else {
      if (neg == 1)
        ans = ans + k;
      else if (k > ans) {
        ans = k - ans;
        aneg = 0;
      } else
        ans = ans - k;
    }
  }
  if (aneg == 1 && ans > 0) printf("-");
  printf("%llu\n", ans);
  return 0;
}
