#include <iostream>
#include <cstring>
#include<vector>
#include <algorithm>
#include<cstdlib>
#include<set>
#include<math.h>
#include<map>
#include<unordered_map>
#include<iomanip>
#include<queue>
#include<bitset>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll MOD = 1000000007;
#define rep(i,a, n) for (ll i = a; i < (ll)(n); i++)
#define vecsort(myVec)  sort(myVec.begin(),myVec.end(),[](const vector<ll> &alpha,const vector<ll> &beta){return alpha[0] < beta[0];});
#define vsort(v) sort(v.begin(),v.end());
#define vdownsort(v) sort(v.begin(),v.end(),greater<ll>());
#define P pair<ll,ll>

ll modpow(ll a, ll n, ll mod)
{
	ll res = 1;
	while (0 < n)
	{
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}



int main()
{

	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n) cin >> a[i];
	vsort(a);
	ll ans, p, q;
	ans = p = q = 0;
	rep(i, 0, n)
	{
		p += a[i] * (n - 1 - i);
		q += a[i] * i;
	}
	ans = q - p;
	cout << ans << endl;


	return 0;
}


#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<a*d-b*c<<endl;
}