#include <bits/stdc++.h>
using namespace std;
priority_queue<long long> pq;
long long n, d, sol = 0, sum = 0;
int main(void) {
  cin >> n;
  while (n--) {
    cin >> d;
    sum += d;
    sol += d;
    pq.push(-d);
  }
  while (pq.size() > 1) {
    long long top = -pq.top();
    pq.pop();
    sol += sum;
    sum -= top;
  }
  cout << sol << endl;
}
