#include <bits/stdc++.h>
using namespace std;
int a[2000010];
map<long long, long long> mp, mp1;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  long long tol = 0;
  long double ans = 0;
  for (int i = 1; i <= n; i++) {
    mp[a[i]]++;
    mp1[a[i]] += a[i];
    tol += a[i];
    int res = i - mp[a[i]] - mp[a[i] + 1] - mp[a[i] - 1];
    long long res1 = tol - mp1[a[i]] - mp1[a[i] - 1] - mp1[a[i] + 1];
    ans += 1ll * res * a[i] - res1;
  }
  cout << fixed << setprecision(0) << ans;
}
