#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <=(int)(n); i++)
#define all(V) V.begin(),V.end()
#define pi 3.1415926535897932384626
#define fi fixed<<setprecision(10)
#define MOD 1000000007
#define ll long long
using namespace std;
//lower_bound(a+l, a+r, x) - a　a[l] から a[r-1] までの中で初めて x 以上となるようなインデックスを返します。
//count(a + l, a + r, x)/find(a + l, a + r + 1, x)
int gcd(ll m,ll n){
  if(n==0) return m;
  return gcd(n,m%n);
}
int fact(ll n){
  ll x=1;REP(i,n)x*=i;
  return x;
}
const ll M = pow(10,9)+7;
vector<ll> fac(1000001); //n!(mod M) 
vector<ll> ifac(1000001); //k!^{M-2} (mod M)
ll mpow(ll x, ll n){ /*x^n(mod M)*/
    ll ans = 1;
    while(n!=0){
      if(n&1) ans = ans*x % MOD;
      x = x*x % MOD;n=n>>1;
    }
  return ans;
}
ll comb(ll a, ll b){
  fac[0] = 1;ifac[0] = 1;
  for(ll i = 0; i<1000000; i++){
    fac[i+1] = fac[i]*(i+1) % MOD;ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD;
  }
  if(a==0&&b==0)return 1;
  if(a<b||a<0)return 0;
  ll tmp=ifac[a-b]*ifac[b]%MOD;
  return tmp*fac[a]%MOD;
}
ll nck(ll a,ll b){
  ll s=1,x=1;
  rep(i,b){
    s=(s*(a-i))/x;
    x++;
    }
    return s;
}
ll perm(ll a, ll b){
  fac[0] = 1;ifac[0] = 1;
  for(ll i = 0; i<1000000; i++){
   fac[i+1] = fac[i]*(i+1) % MOD;ifac[i+1] = ifac[i]*mpow(i+1, M-2) % MOD;
  }
  if(a < b) return 0;
  ll tmp = ifac[a-b] % MOD;
  return tmp * fac[a] % MOD;
}
ll dupc(ll a,ll b){
  fac[0] = 1;ifac[0] = 1;
  for(ll i = 0; i<1000000; i++){
    fac[i+1] = fac[i]*(i+1) % MOD;ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M;
  }
  if(a == 0 && b == 0)return 1;
  if(a < 0 || b == 0)return 0;
  ll tmp = ifac[a-1]* ifac[b] % MOD;
  return tmp * fac[a+b-1] % MOD;
}
void make_prime(){
  vector<int> prime;
  prime.push_back(2);
  for(int i=3;i<=pow(10,5);i++){
    bool pri=true;
    rep(j,prime.size())  if(i%prime[j]==0){ pri=false; break;}
    if(pri) prime.push_back(i);
  }
}
int main(){
  int n;cin>>n;

  vector<ll> a(n);
  rep(i,n) cin>>a[i];

  sort(a.begin(),a.end());

  vector<ll> vec(n+1);
  vec[0]=0;
  rep(i,n) vec[i+1]=vec[i]+a[i];

  ll ans=0;
  rep(i,n){
    ans+=(vec[n]-vec[i])-a[i]*(n-i);
  }
  cout<<ans<<endl;
}
#include <bits/stdc++.h> 
using namespace std;
#define int long long
const int N = 2 * 100010;
int a[N];
int presum[N];
bool cmp(int &a,int &b){
	return a > b;
}
signed main(){
	#ifndef ONLINE_JUDGE
		freopen("sumofdiff.txt","r",stdin);
	#endif
	ios::sync_with_stdio(false);
	int n;cin >> n;
	
	for(int i = 1 ; i <= n ; i++) {
		cin >> a[i];
	}
	sort(a + 1,a+n+1,cmp);
	for(int i = 1 ; i <= n; i++){
		presum[i] = presum[i-1] + a[i];
	}
//	for(int i = 1; i <= n ; i++) cout << a[i] <<",";
//	cout << endl;
	int ans = 0;
	for(int i = 1; i <= n ; i++){
		//(long long )
		ans += (((n-i) * a[i] )- (presum[n] - presum[i]));
	}
	cout << ans;
}
