#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)

#define ALL(x) x.begin(),x.end() 
#define INF 2147483647
#define MOD 1000000007
#define DDD fixed<<setprecision(10)

#define Graph vector<vector<ll>>
#define P pair<ll, ll>
#define V vector<ll>
#define VV vector<vector<ll>>
#define VP vector<pair<ll, ll>>

using namespace std;
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    V a(n);
    REP(i, n) cin >> a[i];

    sort(ALL(a));

    V sum(n);
    sum[0] = a[0];
    FOR(i, 1, n - 1) sum[i] = sum[i - 1] + a[i];

    ll ans = 0;
    FOR(i, 1, n - 1) ans += i * a[i] - sum[i - 1];
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for(int i = 0; i < n; ++i) cin >> v[i];
  sort(v.begin(), v.end());
  long long ans = 0;
  int j = n;
  for(int i = 0; i < n; ++i) {
    ans += v[i] * (n-i-1);
    ans -= v[i] * (n-j);
    --j;
  }
  cout << abs(ans) << endl;
  return 0;
}