#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[N];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
        ll i=(x>>k) & 1;
        if (Tree[r].next[i]==0)
        Tree[r].next[i]=AddNode();
        Tree[r].cnt++;
        r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0){
        ll i=(x>>k) & 1;
        if (Tree[r].next[i]==0) return 0;
        r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        if (a[i]-1>=0) a2=get(a[i]-1);
        else a2=0;
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    cout<<ans;
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define fort(i,a,b) for(ll i=(a);i<=(b);++i)
#define ford(i,a,b) for(ll i=(a);i>=(b);--i)
#define N 200005

using namespace std;

void pool(){
    freopen("t.inp","r",stdin);
    freopen("t.out","w",stdout);
}

ll n,a[N],sum[N],tmp,a1,a2,a3,ans,nT;
struct node{
    ll cnt;
    ll next[2];
} Tree[N];

ll AddNode() {
++nT;
Tree[nT].cnt=
Tree[nT].next[0]=
Tree[nT].next[1]=0;
return nT;
}

void up(ll x){
    ll r=0;
    ford(k,30,0) {
        ll i=(x>>k) & 1;
        if (Tree[r].next[i]==0)
        Tree[r].next[i]=AddNode();
        Tree[r].cnt++;
        r=Tree[r].next[i];
    }
    Tree[r].cnt++;
}

ll get(ll x){
    ll r=0;
    ford(k,30,0){
        ll i=(x>>k) & 1;
        if (Tree[r].next[i]==0) return 0;
        //Tree[r].next[i]=AddNode();
        //Tree[r].cnt++;
        r=Tree[r].next[i];
    }
    return Tree[r].cnt;
}

int main(){

    //pool();
    ios_base::sync_with_stdio(false);
    cin>>n;
    fort(i,1,n){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];
    }
    fort(i,1,n){
        up(a[i]);
        a1=get(a[i]);
        if (a[i]-1>=0) a2=get(a[i]-1);
        else a2=0;
        a3=get(a[i]+1);
        tmp=sum[i]-a1*a[i]-a2*(a[i]-1)-a3*(a[i]+1);
        ans+=(i-a1-a2-a3)*a[i]-tmp;
    }
    printf("%lld",ans);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;typedef long long l;
l n,se,sum;
map<l,l>mp;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (l i=0;i<n;++i){
		l a;cin>>a;
		sum+=(i*a)-se;
		se+=a;
		if(mp.count(a-1))
			sum-=mp[a-1];
		if (mp.count(a+1))
			sum+=mp[a+1];
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<'\n';
}


#include <bits/stdc++.h>
using namespace std ;typedef long long l;
l n,se;
long double ans;
map<l,l>mp;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (l i=0;i<n;i++){
		l x ;
		cin>>x ;
		ans += i * x - se ;
		se += x ;
		if (mp.count(x - 1))
			ans -= mp[x - 1] ;
		if (mp.count(x + 1))
			ans += mp[x + 1] ;
		mp[x]++ ;
	}
	cout<<fixed<<setprecision(0)<<ans<<'\n' ;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
int32_t main(){
	map<l,l>mp;
	l n;cin>>n;
	l se=0,sum=0;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a+1)){
			sum+=mp[a+1];
		}
		if(mp.count(a-1)){
			sum-=mp[a-1];
		}
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
l se;
l sum;
int32_t main(){
	cin.tie(0),cout.tie(0);
	map<l,l>mp;
	l n;cin>>n;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a+1)){
			sum+=mp[a+1];
		}
		if(mp.count(a-1)){
			sum-=mp[a-1];
		}
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
int main(){
	map<l,l>mp;
	l n;cin>>n;
	l se=0,sum=0;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a+1)){
			sum+=mp[a+1];
		}
		if(mp.count(a-1)){
			sum-=mp[a-1];
		}
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<endl;
}


#include <bits/stdc++.h>
using namespace std;typedef long long l;
l n,se,sum;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	l n,se=0,sum=0;
	map<l,l>mp;
	cin>>n;
	for (l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(x-1))
			sum-=mp[x-1];
		if (mp.count(x+1))
			sum+=mp[x+1];
		mp[x]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<'\n';
}


#include <bits/stdc++.h>
using namespace std;typedef long long l;
int main(){
  l n;
  cin>>n;
  l a[n];
  for(int i=0;i<n;++i){
    cin>>a[i];
  }
  l sum=0;
  for(int i=0;i<n-1;++i){
    for(int j=i+1;j<n;j++){
      if(abs(a[i]-a[j])>1){
        sum+=(a[j]-a[i]);
      }
    }
  }
  cout<<(l)sum%(l)(1e18)<<endl;
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
int main(){
	map<l,l>mp;
	l n;cin>>n;
	l se=0;
	long double sum=0;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a+1)){
			sum+=mp[a+1];
		}
		if(mp.count(a-1)){
			sum-=mp[a-1];
		}
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<endl;
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
int main(){
	map<l,l>mp;
	l n;cin>>n;
	l se=0,sum=0;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum=i*a-se;
		se+=a;
		if(mp.count(a+1)) sum+=mp.count(a+1);
		if(mp.count(a-1)) sum-=mp.count(a-1);
		mp[a]++;
	}
	cout<<setprecision(0);
	cout<<fixed<<sum<<endl;
}


#include <bits/stdc++.h>
using namespace std;typedef long long l;
l n,se,sum;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	l n,se=0,sum=0;
	map<l,l>mp;
	cin>>n;
	for (l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a-1))
			sum-=mp[a-1];
		if (mp.count(a+1))
			sum+=mp[a+1];
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<'\n';
}


#include <bits/stdc++.h>
using namespace std ;typedef long long l;
l n,se;
l ans;
map<l,l>mp;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (l i=0;i<n;i++){
		l x ;
		cin>>x ;
		ans+=i * x - se ;
		se+=x ;
		if (mp.count(x - 1))
			ans-=mp[x - 1] ;
		if (mp.count(x + 1))
			ans+=mp[x + 1] ;
		mp[x]++ ;
	}
	cout<<fixed<<setprecision(0)<<ans<<'\n' ;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;typedef long long l;
l n,se,sum;
map<l,l>mp;
int32_t main(){
	ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n;
	for (l i=0;i<n;++i){
		l a;cin>>a;
		sum+=i*a-se;
		se+=a;
		if(mp.count(a-1))
			sum-=mp[a-1];
		if (mp.count(a+1))
			sum+=mp[a+1];
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<'\n';
}


#include<bits/stdc++.h>
using namespace std;typedef long long l;
int main(){
	map<l,l>mp;
	l n;cin>>n;
	l se=0,sum=0;
	for(l i=0;i<n;++i){
		l a;cin>>a;
		sum=i*a-se;
		se+=a;
		if(mp.count(a+1)){
			sum+=mp[a+1];
		}
		if(mp.count(a-1)){
			sum-=mp[a-1];
		}
		mp[a]++;
	}
	cout<<fixed<<setprecision(0)<<sum<<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<intmax_t> a(n,0);

    intmax_t ans=0;
    unordered_map<intmax_t, intmax_t> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    intmax_t c=0;
    intmax_t pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=(c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long double ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=c*a[i];
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<int> a(n,0);

    long long ans=0;
    unordered_map<int,int> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end());
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    int c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=(pre-c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long long ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=(pre-c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    intmax_t ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=(c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long double ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=c*a[i];
        pre+=a[i];
        c++;
    }

    cout.precision(0);
    cout<<fixed<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long double ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=c*a[i];
        pre+=a[i];
        c++;
    }

    cout<<fixed<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long double ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=pre;
        ans-=c*a[i];
        pre+=a[i];
        c++;
    }

    cout.setprecision(0);
    cout<<fixed<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    long long ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end());
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=(pre-c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long double> a(n,0);

    long double ans=0;
    unordered_map<long double, long double> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
         ans+=sh[a[i]-1];
        if(sh.find(a[i]+1)!=sh.end())
         ans-=sh[a[i]+1];
        sh[a[i]]--;
    }

    long double c=0;
    long double pre=0;
    for(int i=n-1; i>=0; i--)
    {
        ans+=(pre-c*a[i]);
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define GROUP_DEC_SIZE 4
class BigInt {
private:
    vector<int> groups;
    void incDigit(int, int);

public:
    BigInt() : groups({ 0 }) {};
    BigInt(int n) : groups({ 0 }) { incDigit(0, n); };
    ~BigInt() {};

    BigInt & operator*(int x);
    BigInt & operator+(const BigInt & rhs) const;
    BigInt & operator*(const BigInt & rhs) const;

    friend ostream & operator<<(ostream &, const BigInt &);
};

void BigInt::incDigit(int idx, int n) {
    if (groups.size() <= idx) groups.resize(idx + 1);

    int dec_mod = pow(10, GROUP_DEC_SIZE);
    groups[idx] += n;
    int mod_g = groups[idx] % dec_mod;
    int extra = groups[idx] / dec_mod;
    groups[idx] = mod_g;

    if (extra > 0) {
        incDigit(idx + 1, extra);
    }
}

BigInt & BigInt::operator*(int x) {
    int extra = 0;
    int dec_mod = pow(10, GROUP_DEC_SIZE);

    for (auto & g : groups) {
        g = g * x + extra;
        int mod_g = g % dec_mod;
        extra = g / dec_mod;
        g = mod_g;
    }

    while (extra > 0) {
        groups.push_back(extra % dec_mod);
        extra /= dec_mod;
    }

    return *this;
}

BigInt & BigInt::operator*(const BigInt & rhs) const {
    BigInt * mul = new BigInt();

    int size_lhs = groups.size();
    int size_rhs = rhs.groups.size();

    for (int i_lhs = 0; i_lhs < size_lhs; i_lhs++) {
        for (int i_rhs = 0; i_rhs < size_rhs; i_rhs++) {
            mul->incDigit(i_lhs + i_rhs, groups[i_lhs] * rhs.groups[i_rhs]);
        }
    }

    return *mul;
}

BigInt & BigInt::operator+(const BigInt & rhs) const {
    BigInt & sum = const_cast<BigInt &>(*this);

    int size_rhs = rhs.groups.size();
    for (int i = 0; i < size_rhs; i++) {
        sum.incDigit(i, rhs.groups[i]);
    }

    return sum;
}

ostream & operator<<(ostream & os, const BigInt & bi) {
    os.fill('0');
    for (auto pg = bi.groups.rbegin(); pg != bi.groups.rend(); pg++) {
        if (pg == bi.groups.rbegin()) {
            os << *pg;
        } else {
            os << std::setw(GROUP_DEC_SIZE) << *pg;
        }
    }
    return os;
}

int main() {

	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
     cin>>n;

    vector<long long> a(n,0);

    BigInt u,v,ans=0;
    unordered_map<long long, long long> sh;

    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        if(sh.find(a[i])==sh.end())
         sh.insert(make_pair(a[i],1));
        else
         sh[a[i]]++;
    }

    for(int i=0; i<n; i++)
    {
        if(sh.find(a[i]-1)!=sh.end())
        {
         u=sh[a[i]-1];
         ans=ans+u;
        }
        if(sh.find(a[i]+1)!=sh.end())
        {
         u=-sh[a[i]+1];
         ans=ans+u;
        }
        sh[a[i]]--;
    }

    long long c=0;
    long long pre=0;
    for(int i=n-1; i>=0; i--)
    {
        u=pre;
        ans=ans+pre;
        u=-c;
        v=a[i];
        u=(u*v);
        ans=ans+u;
        pre+=a[i];
        c++;
    }

    cout<<ans<<endl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

constexpr LL n1e18 = 1000000000000000000LL;

struct LLL {
	LL a, b;

	LLL(LL x) : a(x / n1e18), b(x - a * n1e18) {}

	LLL& operator+=(const LLL& x) {
		a += x.a;
		b += x.b;
		if (b >= n1e18)
			++a, b -= n1e18;
		else if (b <= -n1e18)
			--a, b += n1e18;

		return *this;
	}
};

ostream& operator <<(ostream& os, LLL x) {
	if (x.a > 0 and x.b < 0)
		--x.a, x.b += n1e18;
	else if (x.a < 0 and x.b > 0)
		++x.a, x.b = n1e18 - x.b;

	if (x.a)
		return os << x.a << setw(18) << setfill('0') << abs(x.b);

	return os << x.b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LLL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

constexpr LL n1e18 = 1000000000000000000LL;

struct LLL {
	LL a, b;

	LLL(LL x) : a(x / n1e18), b(x - a * n1e18) {}

	LLL& operator+=(const LLL& x) {
		a += x.a;
		b += x.b;
		if (b >= n1e18)
			++a, b -= n1e18;
		else if (b < 0)
			--a, b += n1e18;

		return *this;
	}
};

ostream& operator <<(ostream& os, const LLL& x) {
	if (x.a)
		return os << x.a << setw(18) << setfill('0') << x.b;

	return os << x.b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LLL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

constexpr LL n1e18 = 1000000000000000000LL;

struct LLL {
	LL a, b;

	LLL(LL x) : a(x / n1e18), b(x - a * n1e18) {}

	LLL& operator+=(const LLL& x) {
		a += x.a;
		b += x.b;
		if (b >= n1e18)
			++a, b -= n1e18;

		return *this;
	}
};

ostream& operator <<(ostream& os, const LLL& x) {
	if (x.a)
		return os << x.a << setw(18) << setfill('0') << x.b;

	return os << x.b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LLL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		res += sum + LL(i) * a;
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		res += sum + LL(i) * a;
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

constexpr LL n1e18 = 1000000000000000000LL;

struct LLL {
	LL a, b;

	LLL(LL x) : a(x / n1e18), b(x - a * n1e18) {}

	LLL& operator+=(const LLL& x) {
		a += x.a;
		b += x.b;
		if (b >= n1e18)
			++a, b -= n1e18;
		else if (b <= -n1e18)
			--a, b += n1e18;

		return *this;
	}
};

ostream& operator <<(ostream& os, const LLL& x) {
	if (x.a)
		return os << x.a << setw(18) << setfill('0') << x.b;

	return os << x.b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LLL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		res += sum + LL(i) * a;
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

constexpr LL n1e18 = 1000000000000000000LL;

struct LLL {
	LL a, b;

	LLL(LL x) : a(x / n1e18), b(x - a * n1e18) {}

	LLL& operator+=(const LLL& x) {
		a += x.a;
		b += x.b;
		if (b >= n1e18)
			++a, b -= n1e18;
		else if ((a != 0 and b < 0) or (a == 0 and b <= -n1e18))
			--a, b += n1e18;

		return *this;
	}
};

ostream& operator <<(ostream& os, const LLL& x) {
	if (x.a)
		return os << x.a << setw(18) << setfill('0') << abs(x.b);

	return os << x.b;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	LLL res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << res << nl;

	return 0;
}


// Krzysztof Małysa
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,n) for (auto i ## __ = (n), i = (a); i <= i ## __; ++i)
#define FORD(i,a,n) for (auto i = (a), i ## __ = (n); i >= i ## __; --i)
#define REP(i,n) FOR(i, 0, n - 1)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int(x.size()))
#define EB emplace_back
#define ST first
#define ND second
#define tpv typedef vector<

typedef long long LL;
typedef pair<int, int> PII;
tpv int> VI;
tpv VI> VVI;
tpv PII> VPII;
tpv LL> VLL;

constexpr char nl = '\n';
#define endl nl

#define ris return *this
#define tem template<class T

tem, class B> inline void mini(T&& a, B&& b) { if (b < a) a = b; }
tem, class B> inline void maxi(T&& a, B&& b) { if (b > a) a = b; }
int ceil2(int x) { return x < 2 ? 1 : 1 << (sizeof(x) * 8 - __builtin_clz(x - 1)); }

tem> struct Dump { T a, b; };
tem> auto dump(T&& x) -> Dump<decltype(x.begin())> { return {ALL(x)}; }
struct Debug {
	~Debug() { cerr << endl; }
	tem> auto operator<<(T x) -> decltype(cerr << x, *this) { cerr << boolalpha << x; return *this; }
	tem> auto operator<<(T x) -> decltype(x.begin(), *this) {
		auto a = x.begin(), b = x.end();
		*this << "{";
		for (; a != b;)
			*this << *a++, *this << (a == b ? "" : " ");
		return *this << "}";
	}
	tem, class B> Debug& operator<<(pair<T, B> p) { ris << "(" << p.ST << ", " << p.ND << ")"; }
	tem> Debug& operator<<(Dump<T> d) {
		*this << "{\n";
		for (T a = d.a, c = a; a != d.b; ++a)
			*this << "  " << distance(c, a) << ": " << *a << '\n';
		ris << "}";
	}
};
struct Foo {tem>Foo& operator<<(T&&) {ris;}};

#ifdef DEBUG
# define DEB(x...) x
# define deb Debug()
#else
# define DEB(...)
# define deb Foo()
#endif
#define imie(x...) #x ": " << (x) << " "
#define LOG(x...) deb << imie(x)
#define DOG(x...) deb << #x ": " << dump(x) << " "

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	cin >> n;
	LL sum = 0;
	map<int, int> M;
	__int128 res = 0;
	FOR (i, 1, n) {
		int a;
		cin >> a;
		sum -= a;
		++M[a];
		for (int k : {a - 1, a + 1})
			res += M[k] * LL(k - a);
		res += sum + LL(i) * a;
		deb << "=================================\n" imie(a) imie(sum) imie(res);
		LOG(M);
	}

	cout << LL(res) << nl;

	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <tuple>
#include <string>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <iomanip>
#include <sstream>
#include <cstdint>
#include <stdexcept>
#include <type_traits>
#include <utility>
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
template<typename T> T gcd(T x, T y){ if(x<y) swap(x,y); while(y>0) { T f = x%y; x = y; y = f; } return x; }
void exgcd(ll a, ll b, ll &d, ll &x, ll &y) {
	if (!b) {d = a; x = 1; y = 0;}
	else {exgcd(b, a % b, d, y, x); y -= x * (a / b);}
}

ll inv(ll a, ll m) {
	ll x, y, d; exgcd(a, m, d, x, y);
	return d == 1 ? ((x%m) + m) % m : -1;
}

#ifndef ONLINE_JUDGE
#define DEBUG 1
#else
#define DEBUG 0
#endif

const int maxn = 200200;

int n;
int a[maxn];

namespace Int128Impl {
	typedef long long int64;
	typedef int       int32;

	// This class is the base class for the Doubler, it provides the
	// helper routines like
	//    int SubDouble(int128_t *A,const int128_t &B,const int borrow);
	//    int128_t DivideDouble(int128_t *A,const int128_t &B);
	//     int shiftleft(int128_t *Value,const int Carry_prm);
	//
	// Which are used by DoubleInt_t to double the size of the passed class.
	// By itself this class is fairly useful if you happen to need something
	// slightly larger than a 64-bit int (large(er) bitfields come to mind).
	//
	typedef class int128_t
	{
		public:
			// construction/casting
			int128_t()                    :Hi(0),Lo(0) {}
			int128_t(const int128_t &orig):Hi(orig.Hi),Lo(orig.Lo) {}
			int128_t(const int64    &orig):Hi(0),Lo(orig) {}
			// assignment
			int128_t &operator= (const int128_t &rhs) {Hi=rhs.Hi;Lo=rhs.Lo;return *this;}
			// compariston
			bool     operator==(const int128_t &rhs) { if ((Hi==rhs.Hi) && (Lo==rhs.Lo)) return true; return false;}
			bool     operator!=(const int128_t &rhs) { if ((Hi==rhs.Hi) && (Lo==rhs.Lo)) return false; return true;}
			bool     operator>=(const int128_t &rhs) { if ((Hi>rhs.Hi) || ( (Hi==rhs.Hi) && (Lo>=rhs.Lo))) return true; return false;}
			bool     operator<=(const int128_t &rhs) { if ((Hi<rhs.Hi) || ( (Hi==rhs.Hi) && (Lo<=rhs.Lo))) return true; return false;}
			bool     operator> (const int128_t &rhs) { if ((Hi>rhs.Hi) || ( (Hi==rhs.Hi) && (Lo>rhs.Lo ))) return true; return false;}
			bool     operator< (const int128_t &rhs) { if ((Hi<rhs.Hi) || ( (Hi==rhs.Hi) && (Lo<rhs.Lo ))) return true; return false;}
			// operations (these are exported for user use)
			int128_t &operator++() { AddDouble(this,1,0); return *this;}
			int128_t &operator--() { SubDouble(this,1,0); return *this;}

			int128_t &operator>>=(const int      rhs)  { for (int x=0;x<rhs;x++) shiftright(this,0); return *this;}
			int128_t &operator<<=(const int      rhs)  { for (int x=0;x<rhs;x++) shiftleft(this,0); return *this;}
			int128_t &operator-=( const int128_t &rhs) { SubDouble(this,rhs,0); return *this;}
			int128_t &operator+=( const int128_t &rhs) { AddDouble(this,rhs,0); return *this;}
			int128_t &operator*=( const int128_t &rhs) { MultiplyDouble(this,rhs); return *this;}
			int128_t &operator/=( const int128_t &rhs) { DivideDouble(this,rhs); return *this;}
			int128_t &operator%=( const int128_t &rhs) { *this=DivideDouble(this,rhs); return *this;}

			int128_t &operator&=( const int64 &rhs) { this->Lo&=rhs; return *this;}
			int128_t &operator|=( const int64 &rhs) { this->Lo|=rhs; return *this;}
			int128_t &operator^=( const int64 &rhs) { this->Lo^=rhs; return *this;}

			int128_t &operator&=( const int128_t &rhs)  { this->Lo&=rhs.Lo; this->Hi&=rhs.Hi; return *this;}
			int128_t &operator|=( const int128_t &rhs)  { this->Lo|=rhs.Lo; this->Hi|=rhs.Hi; return *this;}
			int128_t &operator^=( const int128_t &rhs)  { this->Lo^=rhs.Lo; this->Hi^=rhs.Hi; return *this;}

	//          int128_t &operator~=( const int64 &rhs) { this->Lo~=rhs; return *this;}

			int128_t operator+(   const int128_t &rhs) { int128_t tmp=*this; AddDouble(&tmp,rhs,0); return tmp;}
			int128_t operator-(   const int128_t &rhs) { int128_t tmp=*this; SubDouble(&tmp,rhs,0); return tmp;}
			int128_t operator/(   const int128_t &rhs) { int128_t tmp=*this; DivideDouble(&tmp,rhs); return tmp;}
			int128_t operator%(   const int128_t &rhs) { int128_t tmp=*this; tmp=DivideDouble(&tmp,rhs); return tmp;}
			int128_t operator*(   const int128_t &rhs) { int128_t tmp=*this; MultiplyDouble(&tmp,rhs); return tmp;}

			int128_t operator&(   const int64    &rhs) { int128_t tmp=*this; tmp&=rhs; return tmp;}
			int128_t operator|(   const int64    &rhs) { int128_t tmp=*this; tmp|=rhs; return tmp;}
			int128_t operator^(   const int64    &rhs) { int128_t tmp=*this; tmp^=rhs; return tmp;}

			int128_t operator>>(  const int      &rhs) { int128_t tmp=*this; tmp>>=rhs; return tmp;}
			int128_t operator<<(  const int      &rhs) { int128_t tmp=*this; tmp<<=rhs; return tmp;}

			// input/output routines
			string AsString(const char *format) const;
			char GetLowByte() {return Lo&0xFF;}
	//  protected:
			// these operations are exported for higher level use
			// they don't use the this variable...
			static int SubDouble(int128_t *A,const int128_t &B,const int borrow);
			static int AddDouble(int128_t *A,const int128_t &B,const int carry);
			static int128_t DivideDouble(int128_t *A,const int128_t &B);
			static int128_t MultiplyDouble(int128_t *A,const int128_t &B);
			static int shiftleft(int128_t *Value,const int Carry_prm);
			static int shiftright(int128_t *Value,const int Carry_prm);
	//  private:
			int64 Hi;
			int64 Lo;
			static const int size; //clean up the memory allocation slightly by moving this out of band..
	} int128;
	const int int128::size=128;

	/*bool operator==(const int128 &a,const int128 &b)
	{
		if ((a.Hi==b.Hi) && (a.Lo==b.Lo)) return true;
		return false;
	}*/

	//
	//
	// Assembly implementations of some functions used
	// by the int128 class.. These are just lightweight
	// inline assembly wrappers for x86 instructions
	//
	//

	static inline int64 Multiply64(int64 *A, int64 *B)
	{
		int64 ret; //unessisary the ret should be in RAX
//		asm ("mul %3    \n\t"
//			:"=a" (*A), "=d" (ret)
//			: "a" (*A), "q" (*B)
//		 );
		return ret;
	}

	// take a long word B:A and divide by C, result in A and remainder is returned
	// This is provided for completeness but isn't used because the
	// divide double is implemented as shifts/subtracts like the doubler is
	static inline int64 Divide64(int64 *A, int64 *B,int64 *C)
	{
		int64 ret;
		if (*C==0)
		{
			throw "Divide by zero";
		}
		if (*B>*C) //if the part in the high 64-bits is larger than the divisor then the
		{          //cannot fit in RAX.
			throw "Underflow";
		}
		asm ("div %4    \n\t"
			 :"=a" (*A), "=d" (ret)
			 : "a" (*A), "d" (*B), "q" (*C)
			 :
		 );
		return ret;
	}

	//returns carry and sum in A
	static inline int Add64(int64 *A,const int64 *B,const int64 carry)
	{
		char ret_carry =0;
		asm (
			 "add %3, %0  \n\t"
			 "adc %4, %0  \n\t"
			 "adc %1, %1  \n\t"
	//       "setc %1     \n\t" //appears slower than the add
	//       "cmovcq %3, %1   \n\t"
			 :"=q" (*A), "=q" (ret_carry)
			 :"0" (*A), "q" (carry), "q" (*B), "1" (ret_carry)
			 : "cc"
		);
		return (int)ret_carry;
	}

	// returns if it borroed one...
	static inline int Sub64(int64 *A, const int64 *B,const int borrow)
	{
		int ret_borrow=0;
		asm (
			"clc                \n\t"
			 "cmp $0,%[bor]      \n\t"
			 "je  0f             \n\t"
			 "stc                \n\t"
			 "0:                 \n\t"
			 "sbb %[src], %[dst] \n\t"
			 "adc %[ret_bor], %[ret_bor]\n\t"
			 : [dst] "=q" (*A), [ret_bor] "=r" (ret_borrow)
			 :        "0" (*A),           "1"  (ret_borrow), [src] "q" (*B), [bor] "q" (borrow)
			 : "cc"
			);
		return ret_borrow;
	}

	//
	//
	//          The int128_t methods
	//
	//
	//

	// A-=B; returns borrow
	inline int int128_t::SubDouble(int128_t *A,const int128_t &B,const int borrow)
	{
		int ret_borrow;
		ret_borrow=Sub64(&A->Lo,&B.Lo,borrow);
		ret_borrow=Sub64(&A->Hi,&B.Hi,ret_borrow);
		return ret_borrow;
	}

	inline int int128_t::AddDouble(int128_t *A,const int128_t &B,const int carry)
	{
		int carry_ret=0;
		carry_ret=Add64(&A->Lo,&B.Lo,carry);
		carry_ret=Add64(&A->Hi,&B.Hi,carry_ret);
		return carry_ret;
	}

	// Ha, this is a 256bit multiply, it takes two 128 bit sources and creates a 128bit destination and 128bit overflow..
	// this general code path can be abstracted into a template to generate any arbitraty length multiply as long as
	// we have a 64bit base class... For template testing we could create a 32-bit base class and compare the results
	// with a 64-bit result
	inline int128_t int128_t::MultiplyDouble(int128_t *A,const int128_t &B)
	{
		int128 ret;
		int64  tmp=0;
		int64  col3=0;

		// a 128 bit multiply works like when you were in grade school except that instead of the max value per column being
		// a 9 the max value is 2^64.

		//   ab
		//*  cd
		//------
		//   bd
		//  ad
		//  bc
		//+ac
		//-------
		// wxyz
		int64 a=A->Hi;
		int64 b=A->Lo;
		int64 c=B.Hi;
		int64 d=B.Lo;
		int64 w=0;
		int64 x=0;
		int64 y=0;
		int64 z=0;
		int   carry=0;
		int   carry2=0;
		int64 xp=0;

		y=Multiply64(&b,&d);
		z=b; b=A->Lo;
		x=Multiply64(&a,&d);
		carry=Add64(&y,&a,0);// y+=a;
		a=A->Hi;
		xp=Multiply64(&b,&c);
		carry=Add64(&x,&xp,carry); //x+=xp+carry;
		carry2=Add64(&y,&b,0);   //y+=b;
		w=Multiply64(&a,&c);
		carry2=Add64(&x,&a,carry2);//x+=a;
		// final w fixup
		int64 longcarry=carry2;
		Add64(&w,&longcarry,carry2);

		A->Lo=z;
		A->Hi=y;
		ret.Lo=x;
		ret.Hi=w;

		return ret;
	}

	// Sort of satanic because of all the carry nonsense being propagated in and out of the flags
	// for an arbitrary length integer the fastest way to do this is to put all the rcr's in a loop
	// or unroll them instead of putting all the carry flag checking everywhere
	int int128_t::shiftright(int128 *Value,const int Carry_prm)
	{
		int Carry_ret=0;
		if (Carry_prm)
		{
			asm ("stc\n\t"
				 "rcr $1,%0 \n\t"
				 "rcr $1,%1 \n\t"
				 "adc %2,%2 \n\t"
				 : "=r" (Value->Hi), "=r" (Value->Lo), "=r" (Carry_ret)    //output
				 : "0" (Value->Hi), "1" (Value->Lo), "2" (Carry_ret)     //input
				 : "cc"                                  //clobber
				);
		}
		else
		{
			asm ("clc\n\t"
				 "rcr $1,%0 \n\t"
				 "rcr $1,%1 \n\t"
				 "adc %2,%2 \n\t"
				 : "=q" (Value->Hi), "=q" (Value->Lo), "=q" (Carry_ret)   //output
				 : "0" (Value->Hi), "1" (Value->Lo), "2" (Carry_ret)     //input
				 : "cc"                                  //clobber
				);

		}
		return Carry_ret;
	}

	// This is the left shift version of the above right shift
	int int128_t::shiftleft(int128 *Value,const int Carry_prm)
	{
		char Carry_ret=0;
		if (Carry_prm)
		{
			asm ("stc\n\t"
				 "rcl $1,%1 \n\t"
				 "rcl $1,%0 \n\t"
	//           "setc %2     \n\t" //appears slower than the add
				 "adc %2,%2 \n\t"
				 : "=q" (Value->Hi), "=q" (Value->Lo), "=q" (Carry_ret)    //output
				 : "0" (Value->Hi), "1" (Value->Lo), "2" (Carry_ret)     //input
				 : "cc"                                  //clobber
				);
		}
		else
		{
			asm ("clc\n\t"
				 "rcl $1,%1 \n\t"
				 "rcl $1,%0 \n\t"
	//           "setc %2     \n\t" //appears slower than the add
				 "adc %2,%2 \n\t"
				 : "=q" (Value->Hi), "=q" (Value->Lo), "=q" (Carry_ret)   //output
				 : "0" (Value->Hi), "1" (Value->Lo), "2" (Carry_ret)     //input
				 : "cc"                                  //clobber
				);

		}
		return Carry_ret;
	}

	// from what I understand there are really only a couple of algorithms
	// useful for really long integer divides. My original plan was to
	// do some form of broken up radix 2^64 divide, but that doesn't actually
	// work without making sure the dividend is less than 2^64, if thats the case
	// we could make a really fast arbitrarily long dividend division. I'm afraid I don't
	// want to make that restriction so, I'm back to the old school, shift and subtract method.
	// A=A/B Ret=Remainder
	int128_t int128_t::DivideDouble(int128_t *A,const int128_t &B)
	{
		int128 quotient=*A;
		int128 remainder;//==0

		if ((int128_t)(B)==0) //TODO: fix this const mess
		{
			throw "division by zero";
		}

		for (int x=0;x<A->size;x++)
		{
			int hibit=shiftleft(&quotient,0);
			shiftleft(&remainder,hibit);
			if (remainder>=B)
			{
				SubDouble(&remainder,B,0); //remainder-=*B;
				quotient.Lo|=1; //quotient|=1;
			}
		}

		*A=quotient;
		return remainder;
	}

	// this takes the 64-bit value and prints it out given the formatter
	// this is about as far from efficient as can be
	string AsString(const int64 &Value,const char *format)
	{
		char temp[256];
		string ret;
		switch (format[1])
		{
			case 'd':
				sprintf(temp,"%lld",Value);
				ret=temp;
				break;
//			case 'b':
//				sprintf(temp,"%llb",Value);
//				ret=temp;
//				break;
			case 'X':
				sprintf(temp,"%llX",Value);
				ret=temp;
				break;
			case 'x':
				sprintf(temp,"%llx",Value);
				ret=temp;
				break;
		}
		return ret;
	}

	//string int128_t::AsString(const int128_t &Value,char *format)
	string int128_t::AsString(const char *format) const
	{
		char buff[256];
		char* temp = buff;
		string ret;
		switch (format[1])
		{
			case 'd':
			break;
			case 'b':
				break;
			case 'X':
			case 'x':
			{
				int128_t tmp;
				tmp=*this;
				temp[(tmp.size>>2)]=0;
				for (int x=(tmp.size>>2)-1;x>=0;x--)
				{
					temp[x]=(tmp.Lo)&0xF;
					if (temp[x]>0x9)
					{
						temp[x]+='A'-10;
					}
					else
					{
						temp[x]+='0';
					}
					shiftright(&tmp,0);
					shiftright(&tmp,0);
					shiftright(&tmp,0);
					shiftright(&tmp,0);
				}
			}
			break;
		}
		printf("-- %s\n", temp);
		ret=temp;
		return ret;
	}

	template<class BaseIntT> class DoubleInt_t
	{
		public:
			// construction/casting
			DoubleInt_t()                    :Hi(0),Lo(0),size(Hi.size*2) {}
			DoubleInt_t(const DoubleInt_t &orig):Hi(orig.Hi),Lo(orig.Lo),size(Hi.size*2) {}
			DoubleInt_t(const BaseIntT    &orig):Hi(0),Lo(orig),size(Hi.size*2) {}
			DoubleInt_t(const int64       &orig):Hi(0),Lo(orig),size(Hi.size*2) {}
			// assignment
			DoubleInt_t &operator= (const DoubleInt_t &rhs) {Hi=rhs.Hi;Lo=rhs.Lo;return *this;}
			// compariston
			bool     operator==(const DoubleInt_t &rhs) { if ((Hi==rhs.Hi) && (Lo==rhs.Lo)) return true; return false;}
			bool     operator!=(const DoubleInt_t &rhs) { if ((Hi==rhs.Hi) && (Lo==rhs.Lo)) return false; return true;}
			bool     operator>=(const DoubleInt_t &rhs) { if ((Hi>rhs.Hi) || ( (Hi==rhs.Hi) && (Lo>=rhs.Lo))) return true; return false;}
			bool     operator<=(const DoubleInt_t &rhs) { if ((Hi<rhs.Hi) || ( (Hi==rhs.Hi) && (Lo<=rhs.Lo))) return true; return false;}
			bool     operator> (const DoubleInt_t &rhs) { if ((Hi>rhs.Hi) || ( (Hi==rhs.Hi) && (Lo>rhs.Lo ))) return true; return false;}
			bool     operator< (const DoubleInt_t &rhs) { if ((Hi<rhs.Hi) || ( (Hi==rhs.Hi) && (Lo<rhs.Lo ))) return true; return false;}
			// operations (these are exported for user use)
			DoubleInt_t &operator>>=(const int      rhs)  { for (int x=0;x<rhs;x++) shiftright(this,0); return *this;}
			DoubleInt_t &operator<<=(const int      rhs)  { for (int x=0;x<rhs;x++) shiftleft(this,0); return *this;}
			DoubleInt_t &operator-=( const DoubleInt_t &rhs) { SubDouble(this,rhs,0); return *this;}
			DoubleInt_t &operator+=( const DoubleInt_t &rhs) { AddDouble(this,rhs,0); return *this;}
			DoubleInt_t &operator*=( const DoubleInt_t &rhs) { MultiplyDouble(this,rhs); return *this;}
			DoubleInt_t &operator/=( const DoubleInt_t &rhs) { DivideDouble(this,rhs); return *this;}
			DoubleInt_t &operator%=( const DoubleInt_t &rhs) { *this=DivideDouble(this,rhs); return *this;}

			DoubleInt_t &operator&=( const int64 &rhs) { this->Lo&=rhs; return *this;}
			DoubleInt_t &operator|=( const int64 &rhs) { this->Lo|=rhs; return *this;}
			DoubleInt_t &operator^=( const int64 &rhs) { this->Lo^=rhs; return *this;}

			DoubleInt_t &operator&=( const DoubleInt_t &rhs) { this->Lo&=rhs.Lo; this->Hi&=rhs.Hi; return *this;}
			DoubleInt_t &operator|=( const DoubleInt_t &rhs) { this->Lo|=rhs.Lo; this->Hi|=rhs.Hi; return *this;}
			DoubleInt_t &operator^=( const DoubleInt_t &rhs) { this->Lo^=rhs.Lo; this->Hi^=rhs.Hi; return *this;}

			DoubleInt_t operator+(   const DoubleInt_t &rhs) { DoubleInt_t tmp=*this; AddDouble(&tmp,rhs,0); return tmp;}
			DoubleInt_t operator-(   const DoubleInt_t &rhs) { DoubleInt_t tmp=*this; SubDouble(&tmp,rhs,0); return tmp;}
			DoubleInt_t operator/(   const DoubleInt_t &rhs) { DoubleInt_t tmp=*this; DivideDouble(&tmp,rhs); return tmp;}
			DoubleInt_t operator%(   const DoubleInt_t &rhs) { DoubleInt_t tmp=*this; tmp=DivideDouble(&tmp,rhs); return tmp;}
			DoubleInt_t operator*(   const DoubleInt_t &rhs) { DoubleInt_t tmp=*this; MultiplyDouble(&tmp,rhs); return tmp;}

			DoubleInt_t operator&(   const int64    &rhs) { DoubleInt_t tmp=*this; tmp.Lo&=rhs; return tmp;}
			DoubleInt_t operator|(   const int64    &rhs) { DoubleInt_t tmp=*this; tmp.Lo|=rhs; return tmp;}
			DoubleInt_t operator^(   const int64    &rhs) { DoubleInt_t tmp=*this; tmp.Lo^=rhs; return tmp;}

			DoubleInt_t operator>>(  const int      &rhs) { DoubleInt_t tmp=*this; tmp>>=rhs; return tmp;}
			DoubleInt_t operator<<(  const int      &rhs) { DoubleInt_t tmp=*this; tmp<<=rhs; return tmp;}

			// consider overridding printf until then use AsString
			string AsString(const char *format);
			void   FromString(const char *Source_prm);
			char   GetLowByte() {return Lo.GetLowByte();}
	//  protected:
			// these operations are exported for higher level use
			// they don't use the this variable...
			static int SubDouble(DoubleInt_t *A,const DoubleInt_t &B,const int borrow);
			static int AddDouble(DoubleInt_t *A,const DoubleInt_t &B,const int carry);
			static DoubleInt_t DivideDouble(DoubleInt_t *A,const DoubleInt_t &B);
			static DoubleInt_t MultiplyDouble(DoubleInt_t *A,const DoubleInt_t &B);
			static int shiftleft(DoubleInt_t *Value,const int Carry_prm);
			static int shiftright(DoubleInt_t *Value,const int Carry_prm);
	//  private:
			BaseIntT Hi;
			BaseIntT Lo;
			const int size;
	};

	// throw exceptions on overflow/underflow etc..
	template<class BaseInnT> class OverflowException_t
	{

	};

	template<class BaseIntT, class ExponentT> class Floating_t
	{
	};

	// normal number systems don't support -0 so we don't either...
	// this class just takes an unsigned base and adds a sign to it,
	// it does this without changing the bit encoding of the value, so its
	// not exactly efficient for certain operations, on the other hand we don't then have
	// to worry about sign extension or anything like that...
	template<class BaseIntT> class SignedInt_t
	{
		public:
			// construction/casting
			SignedInt_t()                    :Value(0),Negative(0) {}
			SignedInt_t(const SignedInt_t &orig):Value(orig.Value),Negative(orig.Negative) {}
			SignedInt_t(const BaseIntT    &orig):Value(orig),Negative(0) {}
			SignedInt_t(const int64       &orig):Value(orig),Negative(0) { if (orig<0) { Negative=1; Value^=BaseIntT(-1); Value+=BaseIntT(1);}} //ugly!
			// assignment
			SignedInt_t &operator= (const SignedInt_t &rhs) {Value=rhs.Value; Negative=rhs.Negative; return *this;}
			// compariston (some of thse operators could use a little teaking for efficiency)
			bool     operator==(const SignedInt_t &rhs) { if ((Value==rhs.Value) && (Negative==rhs.Negative)) return true; return false;}
			bool     operator!=(const SignedInt_t &rhs) { if ((Value==rhs.Value) && (Negative==rhs.Negative)) return false; return true;}
			bool     operator>=(const SignedInt_t &rhs) { if ((Negative==1) && (rhs.Negative==1))   {   if (Value<=rhs.Value)   {   return true;    }   return false;   }
														  else if ((Negative==0) && (rhs.Negative==0))  {   if (Value>=rhs.Value)   {   return true;    }   return false; }
														  else if (Negative==1) {   return false;   }   else    {   return true;    }   return false; }
			bool     operator<=(const SignedInt_t &rhs) { if (*this==rhs) return true; else if (*this>=rhs) return false; else return true;}
			bool     operator> (const SignedInt_t &rhs) { if (*this==rhs) return false; else return (*this>=rhs);}
			bool     operator< (const SignedInt_t &rhs) { if (*this==rhs) return false; else return !(*this>=rhs);}
			// operations (these are exported for user use), many of these operations are "wierd" because they don't affect the sign aka shift and bit instructions maintain signage
			SignedInt_t &operator>>=(const int      rhs)  { Value>>=rhs; return *this;}
			SignedInt_t &operator<<=(const int      rhs)  { Value<<=rhs; return *this;}
			SignedInt_t &operator-=( const SignedInt_t &rhs) { SubDouble(this,rhs,0);  return *this;}
			SignedInt_t &operator+=( const SignedInt_t &rhs) { AddDouble(this,rhs,0); return *this;}
			SignedInt_t &operator*=( const SignedInt_t &rhs) { MultiplyDouble(this,rhs); return *this;}
			SignedInt_t &operator/=( const SignedInt_t &rhs) { DivideDouble(this,rhs); return *this;}

			SignedInt_t &operator&=( const int64 &rhs) { Value&=rhs; return *this;}
			SignedInt_t &operator|=( const int64 &rhs) { Value|=rhs; return *this;}
			SignedInt_t &operator^=( const int64 &rhs) { Value^=rhs; return *this;}

			SignedInt_t &operator&=( const SignedInt_t &rhs) { Value&=rhs.Value; return *this;}
			SignedInt_t &operator|=( const SignedInt_t &rhs) { Value|=rhs.Value; return *this;}
			SignedInt_t &operator^=( const SignedInt_t &rhs) { Value^=rhs.Value; return *this;}

			SignedInt_t operator+(   const SignedInt_t &rhs) { SignedInt_t tmp=*this; AddDouble(&tmp,rhs,0); return tmp;}
			SignedInt_t operator-(   const SignedInt_t &rhs) { SignedInt_t tmp=*this; SubDouble(&tmp,rhs,0); return tmp;}
			SignedInt_t operator/(   const SignedInt_t &rhs) { SignedInt_t tmp=*this; DivideDouble(&tmp,rhs); return tmp;}
			SignedInt_t operator*(   const SignedInt_t &rhs) { SignedInt_t tmp=*this; MultiplyDouble(&tmp,rhs); return tmp;}

			SignedInt_t operator&(   const int64    &rhs) { SignedInt_t tmp=*this; tmp.Value&=rhs; return tmp;}
			SignedInt_t operator|(   const int64    &rhs) { SignedInt_t tmp=*this; tmp.Value|=rhs; return tmp;}
			SignedInt_t operator^(   const int64    &rhs) { SignedInt_t tmp=*this; tmp.Value^=rhs; return tmp;}

			SignedInt_t operator>>(  const int      &rhs) { SignedInt_t tmp=*this; tmp>>=rhs; return tmp;}
			SignedInt_t operator<<(  const int      &rhs) { SignedInt_t tmp=*this; tmp<<=rhs; return tmp;}

			// the following pretty much the same as above, in both cases we are in temp hell

			// consider overridding printf until then use AsString
			//string AsString(const SignedInt_t &Value,char *format);
			string AsString(const char *format) { string ret=Value.AsString(format); if (Negative) ret.insert(0,"-"); return ret;}
			void   FromString(const char *Source_prm);
			char   GetLowByte() {return Value.GetLowByte();}
	//  protected:
			// these operations are exported for higher level use
			// they don't use the this variable...
			static int SubDouble(SignedInt_t *A,const SignedInt_t &B,const int borrow);
			static int AddDouble(SignedInt_t *A,const SignedInt_t &B,const int carry);
			static SignedInt_t DivideDouble(SignedInt_t *A,const SignedInt_t &B);
			static SignedInt_t MultiplyDouble(SignedInt_t *A,const SignedInt_t &B);
			static int shiftleft(SignedInt_t *Value_prm,const int Carry_prm) { return shiftleft(Value_prm->Value,Carry_prm);}
			static int shiftright(SignedInt_t *Value_prm,const int Carry_prm) { return shiftright(Value_prm->Value,Carry_prm);}

	//  private:
			BaseIntT Value;
			int Negative;
	};

	template<class BaseIntT> int DoubleInt_t<BaseIntT>::SubDouble(DoubleInt_t *A,const DoubleInt_t &B,const int borrow)
	{
		int ret_borrow;
		ret_borrow=BaseIntT::SubDouble(&A->Lo,B.Lo,borrow);
		ret_borrow=BaseIntT::SubDouble(&A->Hi,B.Hi,ret_borrow);
		return ret_borrow;
	}

	//
	//
	//          The DoubleInt_t methods
	//
	//
	//

	template<class BaseIntT> int DoubleInt_t<BaseIntT>::AddDouble(DoubleInt_t *A,const DoubleInt_t &B,const int carry)
	{
		int carry_ret=0;
		carry_ret=BaseIntT::AddDouble(&A->Lo,B.Lo,carry);
		carry_ret=BaseIntT::AddDouble(&A->Hi,B.Hi,carry_ret);
		return carry_ret;
	}

	template<class BaseIntT> DoubleInt_t<BaseIntT> DoubleInt_t<BaseIntT>::MultiplyDouble(DoubleInt_t *A,const DoubleInt_t &B)
	{
		DoubleInt_t ret;
		BaseIntT  tmp=0;
		BaseIntT  col3=0;

		// a 128 bit multiply works like when you were in grade school except that instead of the max value per column being
		// a 9 the max value is 2^64.

		//   ab
		//*  cd
		//------
		//   bd
		//  ad
		//  bc
		//+ac
		//-------
		// wxyz
		BaseIntT a=A->Hi;
		BaseIntT b=A->Lo;
		BaseIntT c=B.Hi;
		BaseIntT d=B.Lo;
		BaseIntT w=0;
		BaseIntT x=0;
		BaseIntT y=0;
		BaseIntT z=0;
		int   carry=0;
		int   carry2=0;
		BaseIntT xp=0;

		y=BaseIntT::MultiplyDouble(&b,d);
		z=b; b=A->Lo;
		x=BaseIntT::MultiplyDouble(&a,d);
		carry=BaseIntT::AddDouble(&y,a,0);//    y+=a;
		a=A->Hi;
		xp=BaseIntT::MultiplyDouble(&b,c);
		carry=BaseIntT::AddDouble(&x,xp,carry); //x+=xp+carry;
		carry2=BaseIntT::AddDouble(&y,b,0);   //y+=b;
		w=BaseIntT::MultiplyDouble(&a,c);
		carry2=BaseIntT::AddDouble(&x,a,carry2);//x+=a;
		// final w fixup
		BaseIntT longcarry=carry2;
		BaseIntT::AddDouble(&w,longcarry,carry2);

		A->Lo=z;
		A->Hi=y;
		ret.Lo=x;
		ret.Hi=w;

		return ret;
	}

	template<class BaseIntT> int DoubleInt_t<BaseIntT>::shiftright(DoubleInt_t *Value,const int Carry_prm)
	{
		int carry_ret;
		carry_ret=BaseIntT::shiftright(&Value->Hi,Carry_prm);
		carry_ret=BaseIntT::shiftright(&Value->Lo,carry_ret);
		return carry_ret;
	}

	template<class BaseIntT> int DoubleInt_t<BaseIntT>::shiftleft(DoubleInt_t *Value,const int Carry_prm)
	{
		int carry_ret;
		carry_ret=BaseIntT::shiftleft(&Value->Lo,Carry_prm);
		carry_ret=BaseIntT::shiftleft(&Value->Hi,carry_ret);
		return carry_ret;
	}

	template<class BaseIntT> DoubleInt_t<BaseIntT> DoubleInt_t<BaseIntT>::DivideDouble(DoubleInt_t *A,const DoubleInt_t &B)
	{
		DoubleInt_t quotient=*A;
		DoubleInt_t remainder;//==0

		if ((DoubleInt_t)(B)==0) //TODO: fix this const mess
		{
			throw "division by zero";
		}

		for (int x=0;x<A->size;x++)
		{
			int hibit=shiftleft(&quotient,0);
			shiftleft(&remainder,hibit);
			if (remainder>=B)
			{
				SubDouble(&remainder,B,0); //remainder-=*B;
				quotient.Lo|=1; //quotient|=1;
			}
		}

		*A=quotient;
		return remainder;
	}

	template<class BaseIntT> string DoubleInt_t<BaseIntT>::AsString(const char *format)
	{
		string ret;
		switch (format[1])
		{
			case 'd':
			{
				char temp[2];
				DoubleInt_t tmp;
				int x=0;
				tmp=*this;
				if (tmp==0)
				{
					ret="0";
				}
				else
				{
					ret="";
					temp[1]='\0';

					while (tmp!=0)
					{
						DoubleInt_t remainder=DivideDouble(&tmp,DoubleInt_t(10)); //TODO: convert to something a little faster...
						temp[0]=remainder.GetLowByte()+'0';
						ret.insert(0,string(temp));
					}
				}
			}
			break;
			case 'b':
			{
				DoubleInt_t tmp;
				int x=0;
				tmp=*this;
				char temp[tmp.size+2];

				for (int x=0;x<tmp.size;x++)
				{
					temp[x]=tmp.GetLowByte()&0x01+'0';
					shiftright(&tmp,0);
				}
				temp[tmp.size]='\0';
				ret=temp;
			}
			break;
			case 'X':
			case 'x':
			{
				DoubleInt_t tmp;
				tmp=*this;
				char *temp=new char[(tmp.size>>2)+2];
				temp[(tmp.size>>2)]=0;
				for (int x=(tmp.size>>2)-1;x>=0;x--)
				{
					temp[x]=(tmp.Lo).GetLowByte()&0xF;
					if (temp[x]>0x9)
					{
						temp[x]+='A'-10;
					}
					else
					{
						temp[x]+='0';
					}
					shiftright(&tmp,0);
					shiftright(&tmp,0);
					shiftright(&tmp,0);
					shiftright(&tmp,0);
				}
				ret=temp;
				delete[] temp;
			}
			break;
		}
		return ret;
	}

	// takes the value as a base 10 or base 16 string and converts it to the big integer type
	template<class BaseIntT> void DoubleInt_t<BaseIntT>::FromString(const char *Source_prm)
	{
		int start=0;
		int base=10;
		Hi=Lo=0;
		while (Source_prm[start]!='\0')
		{
			if (Source_prm[start]=='0')
			{
				if (Source_prm[start+1]=='x')
				{
					base=16;
					start+=2;
				}
				break;
			}
			if ((Source_prm[start]>='0') && (Source_prm[start]<='9'))
			{
				break;
			}
			start++;
		}
		// ok we found the beginning of the string..
		if (base==10)
		{
			DoubleInt_t multconst(10);
			while ((Source_prm[start]<='9') && (Source_prm[start]>='0'))
			{
				char tmp=Source_prm[start]-'0';
				MultiplyDouble(this,multconst);
				AddDouble(this,DoubleInt_t(tmp),0);
				start++;
			}
		}
		else
		{
			char upper=toupper(Source_prm[start]);
			while (((upper<='9') && (upper>='0')) || ((upper>='A') && (upper<='F')))
			{
				char tmp;
				if (upper<='9')
				{
					tmp=upper-'0';
				}
				else
				{
					tmp=upper-'A';
				}
				shiftleft(this,0);
				shiftleft(this,0);
				shiftleft(this,0);
				shiftleft(this,0);
				Lo|=int64(tmp);
				start++;
				upper=toupper(Source_prm[start]);
			}
		}
	}

	template<class BaseIntT> int SignedInt_t<BaseIntT>::AddDouble(SignedInt_t *A,const SignedInt_t &B,const int carry)
	{
		if (carry!=0)
		{
			throw "non zero carry passed to SignedInt add";
		}
		if (A->Negative==B.Negative) //same sign.. just add them, don't modify the sign
		{
			return BaseIntT::AddDouble(&A->Value,B.Value,carry);
		}
		else
		{
			// ok now here is the fun with non two complement numbers

			// first detect which one has the larger magnitude
			if (A->Value>B.Value)
			{
				//A will maintain its sign, but subtract B from A
				if (BaseIntT::SubDouble(&A->Value,B.Value,0)!=0)
				{
					throw "borrow nessisary during add!"; //probably a bug...
				}
				return 0; //there shouldn't be a carry in this case
			}
			else
			{
				if (A->Value==B.Value)
				{
					//rare shortcut....
					A->Value=0;
					A->Negative=0;
					return 0;
				}
				else // (B.Value>A.Value)
				{
					//A will have B's Sign..

					// this is a lot sucky...
					BaseIntT tmp=A->Value;
					A->Value=B.Value;
					if (BaseIntT::SubDouble(&A->Value,tmp,0)!=0)
					{
						throw "borrow nessisary during add!"; //probably a bug...
					}
					A->Negative=B.Negative;
					return 0; //there shouldn't be a carry in this case
				}
			}
		}
	}

	// flip the sign of A and add them...
	template<class BaseIntT> int SignedInt_t<BaseIntT>::SubDouble(SignedInt_t *A,const SignedInt_t &B,const int borrow)
	{
		A->Negative^=1; //negate the sign with xor <chuckle>
		return AddDouble(A,B,0);
	}

	//TODO make a finalizer class which sits between this class and the double template and throws overflow exceptions...
	template<class BaseIntT> SignedInt_t<BaseIntT> SignedInt_t<BaseIntT>::MultiplyDouble(SignedInt_t *A,const SignedInt_t &B)
	{
		BaseIntT::MultiplyDouble(&A->Value,B.Value);
		if (A->Value==0)
		{
			A->Negative=0;
		}
		else
		{
			A->Negative^=B.Negative; //flip sign as nessiary
		}
		return *A;
	}

	template<class BaseIntT> SignedInt_t<BaseIntT> SignedInt_t<BaseIntT>::DivideDouble(SignedInt_t *A,const SignedInt_t &B)
	{
		SignedInt_t tmp;
		tmp.Value=BaseIntT::DivideDouble(&A->Value,B.Value);
		if (A->Value==0)
		{
			A->Negative=0;
		}
		else
		{
			A->Negative^=B.Negative; //flip sign as nessiary
		}
		return tmp.Value;
	}

	template<class BaseIntT> void SignedInt_t<BaseIntT>::FromString(const char *Source_prm)
	{
		int start=0;
		Negative=0;

		while (Source_prm[start]!='\0')
		{
			if (Source_prm[start]=='0')
			{
				if (Source_prm[start+1]=='x')
				{
					// hex start
					Value.FromString(&Source_prm[start]);
					break;
				}
			}
			if ((Source_prm[start]>='0') && (Source_prm[start]<='9'))
			{
				// normal decimal start
				Value.FromString(&Source_prm[start]);
				break;
			}
			if (Source_prm[start]=='-')
			{
				Negative=1;
			}
			start++;
		}
		if (Source_prm[start]=='\0')
		{
			Value=0;
		}
	}

	template<typename T>
	std::ostream & operator<<(std::ostream & stream, const SignedInt_t<T> & rhs){
		if (stream.flags() & stream.oct){
			stream << "ERR";
		}
		else if (stream.flags() & stream.dec){
			stream << rhs.AsString("%d") << " : " << rhs.AsString("%x");
		}
		else if (stream.flags() & stream.hex){
			stream << rhs.AsString("%x");
		}
		return stream;
	}
};

typedef Int128Impl::SignedInt_t<Int128Impl::DoubleInt_t<Int128Impl::int128_t> > bigint;

int main(int argc, char *argv[]) {
	std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
	#if DEBUG
	freopen("/tmp/in.txt", "r", stdin);
	while(cin>>n)
	#else
	cin >> n;
	#endif
	{
		map<ll,bigint> bs, b1;
		bigint r = 0;
		bigint nbr = 0;
		bigint ts = 0;
		for(int i=0;i<n;i++) {
			ll x; cin >> x;
			bigint nbr0 = b1[x+1] + b1[x] + b1[x-1];
			bigint s0 = bs[x+1] + bs[x] + bs[x-1];

			r += (nbr - nbr0) * x - (ts-s0);

			bs[x] += x;
			b1[x] += 1;
			ts += x;
			nbr += 1;
		}

		cout << r.AsString("%d") << endl;
	}
	return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <tuple>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
using namespace std;

typedef long double ll;

#ifndef ONLINE_JUDGE
#define DEBUG 1
#else
#define DEBUG 0
#endif

const int maxn = 200200;

int n;
int a[maxn];

int main(int argc, char *argv[]) {
	std::cin.sync_with_stdio(false);std::cin.tie(nullptr);
	#if DEBUG
	freopen("/tmp/in.txt", "r", stdin);
	while(cin>>n)
	#else
	cin >> n;
	#endif
	{
		map<ll,ll> bs, b1;
		ll r = 0;
		ll nbr = 0;
		ll ts = 0;
		for(int i=0;i<n;i++) {
			ll x; cin >> x;
			ll nbr0 = b1[x+1] + b1[x] + b1[x-1];
			ll s0 = bs[x+1] + bs[x] + bs[x-1];

			r += (x) * (nbr - nbr0) - (ts-s0);

			bs[x] += x;
			b1[x] += 1;
			ts += x;
			nbr++;
		}

		cout << r << endl;
	}
	return 0;
}