#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long sum = 0, sum_mas;
  cin >> n;
  vector<int> mas;
  for (int i = 0, temp = 0; i < n; i++) {
    cin >> temp;
    sum += temp;
    mas.push_back(temp);
  }
  sum_mas = sum;
  sort(mas.begin(), mas.end());
  for (int i = 0; i < n; i++) {
    sum += sum_mas;
    sum_mas -= mas[i];
  }
  cout << sum - mas[mas.size() - 1];
  return 0;
}
