#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<long long> a(n);
  long long i;
  for (i = 0; i < n; i++) cin >> a[i];
  map<long long, long long> m;
  long long add = 0;
  for (i = 0; i < n; i++) {
    auto it = m.find(a[i]);
    if (it != m.end()) {
      pair<long long, long long> p = *it;
      long long val = p.second;
      m.erase(a[i]);
      m.insert(make_pair(a[i], val + 1));
    } else {
      m.insert(make_pair(a[i], 1));
    }
    auto itneg = m.find(a[i] - 1);
    auto itpos = m.find(a[i] + 1);
    if (itneg != m.end()) {
      pair<long long, long long> p = *itneg;
      add -= p.second;
    }
    if (itpos != m.end()) {
      pair<long long, long long> p = *itpos;
      add += p.second;
    }
  }
  long long ans = add;
  long long ch = 0;
  for (i = 0; i < n; i++) {
    ans += a[i] * (i * 2 - (n - 1));
    while (ans >= 1000000000000000000) {
      ch++;
      ans -= 1000000000000000000;
    }
    while (ans < 0) {
      ch--;
      ans += 1000000000000000000;
    }
  }
  if (ch >= 0) {
    if (ch == 0)
      cout << ans << endl;
    else {
      cout << ch;
      vector<int> nums(18);
      for (i = 17; i >= 0; i--) {
        nums[i] = ans % 10;
        ans /= 10;
      }
      for (i = 0; i < 18; i++) {
        cout << nums[i];
      }
      cout << endl;
    }
  } else {
    ch++;
    ans -= 1000000000000000000;
    if (ch == 0) {
      cout << ans << endl;
    } else {
      ans = abs(ans);
      cout << '-';
      if (ch < 0) cout << abs(ch);
      vector<int> nums(18);
      for (i = 17; i >= 0; i--) {
        nums[i] = ans % 10;
        ans /= 10;
      }
      for (i = 0; i < 18; i++) {
        cout << nums[i];
      }
      cout << endl;
    }
  }
}
