#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, c = 0, j, temp = 0, t2 = 0, i;
  cin >> n;
  long long a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i];
    c = c + a[i];
  }
  t2 = c;
  sort(a, a + n);
  for (j = 0; j < n; j++) {
    if (j != n - 1) {
      c = c + a[j];
    }
    temp = a[j];
    a[j] = t2 - temp;
    t2 = t2 - temp;
  }
  for (j = 0; j < n; j++) {
    c = c + a[j];
  }
  cout << c << endl;
  return (0);
}
