#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  ll b = n - 1;
  rep(i, n) {
    ans += a[i] * b;
    b -= 2;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void) {
  int n; cin >> n;
  long long a[n];
  long long b[n] = {};
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a, a + sizeof(a)/sizeof(a[0]));
  for(int i = 0; i < n-1; ++i) {
    if(i == 0){
      b[n-1] = a[n-1]-a[n-2];
    } else {
      b[n-1-i] = b[n-i] + (i + 1)*(a[n-1-i] - a[n-2-i]);
    }
  }
  long long ans = 0;
  for(int i = 1; i < n; ++i) {
    ans += b[i];
  }
  cout << ans << "\n";
  return 0;
}