#include <bits/stdc++.h>
using namespace std;
long long a[300100], dp[300100];
int main() {
  long long n, ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long i = n - 1; i >= 0; i--) {
    dp[i] = dp[i + 1] + a[i];
    ans += dp[i] + a[i];
  }
  ans -= a[n - 1];
  cout << ans;
  return 0;
}
