#include <bits/stdc++.h>
using namespace std;
long long ar[200010], sum[200010];
map<long long, int> mopa;
int main() {
  ios::sync_with_stdio(false);
  int i, j, n, m;
  long long a, b, c = 0, d, x, y, z = 0, sx, sy, sz;
  unsigned long long ans = 0, ans2 = 0;
  cin >> n;
  m = n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> ar[i];
    c += ar[i];
    sum[i] = c;
    mopa[ar[i]]++;
  }
  for (int i = 0; i <= n - 1; i++) {
    x = mopa[ar[i] - 1];
    y = mopa[ar[i]] - 1;
    z = mopa[ar[i] + 1];
    sx = x * (ar[i] - 1);
    sy = y * (ar[i]);
    sz = z * (ar[i] + 1);
    a = m - (x + y + z);
    d = c - (sx + sy + sz);
    if ((d - a * ar[i]) > 0)
      ans += (d - a * ar[i]);
    else
      ans2 += (-1 * (d - a * ar[i]));
    m--;
    c -= ar[i];
    mopa[ar[i]]--;
  }
  if (ans >= ans2)
    cout << ans - ans2 << '\n';
  else
    cout << '-' << ans2 - ans << '\n';
  return 0;
}
