#include <bits/stdc++.h>
using namespace std;
struct Reverse {
  bool operator()(int x, int y) { return y < x; }
};
int main() {
  priority_queue<int, vector<int>, Reverse> Q;
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    int elem;
    cin >> elem;
    sum += elem;
    Q.push(elem);
  }
  long long res = 0;
  while (Q.size() != 1) {
    int elem = Q.top();
    Q.pop();
    res += elem + sum;
    sum -= elem;
  }
  res += Q.top();
  cout << res;
  return 0;
}
