#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<long long> v, sum;
  sum.push_back(0);
  int n;
  long long cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  sort(v.begin(), v.end(), greater<int>());
  for (int i = 0; i < v.size(); i++) sum.push_back(sum[i] + v[i]);
  if (n == 1) return (cout << sum[1] << endl, 0);
  if (n == 2) return (cout << sum[2] * 2 << endl, 0);
  for (int i = 2; i < sum.size() - 1; i++) cnt += sum[i];
  cout << cnt + sum[sum.size() - 1] * 2 << endl;
  return 0;
}
