#include <bits/stdc++.h>
using namespace std;
vector<int> arr;
multiset<int> myset;
int main() {
  int n;
  cin >> n;
  long long suma = 0;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    myset.insert(t);
    suma += t;
  }
  long long k = suma;
  while (myset.size() >= 1) {
    multiset<int>::iterator it = myset.begin();
    if (myset.size() >= 2) suma += *it;
    k -= *it;
    myset.erase(it);
    if (myset.size() > 0) suma += k;
    if (myset.size() == 0) break;
  }
  cout << suma << endl;
}
