#include <bits/stdc++.h>
using namespace std;
int arr[300005];
int main() {
  int n;
  cin >> n;
  long long sum = 0, finalsum = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  finalsum = sum;
  sort(arr, arr + n);
  stack<long long> st;
  for (int i = n - 1; i >= 0; i--) st.push(arr[i]);
  while (st.size() > 1) {
    finalsum = finalsum + st.top();
    sum = sum - st.top();
    finalsum = finalsum + sum;
    st.pop();
  }
  cout << finalsum << endl;
  return 0;
}
