#include <bits/stdc++.h>
using namespace std;
long long sum;
int v[300000];
bool Compare(int i, int j) { return i > j; }
int Sum(int* v, int n) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += v[i];
  }
  return sum;
}
int main() {
  int n;
  int group;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    sum += v[i];
  }
  if (n == 1) {
    cout << v[0] << endl;
    return 0;
  }
  sort(v, v + n, Compare);
  long long sum_tmp = sum - v[n - 1];
  sum *= 2;
  n--;
  while (n != 1) {
    sum += sum_tmp;
    sum_tmp -= v[n - 1];
    n--;
  }
  cout << sum << endl;
  return 0;
}
