#include <bits/stdc++.h>
using namespace std;
deque<int> dq;
vector<int> pre;
int main() {
  int N;
  cin >> N;
  pre.resize(N);
  dq.resize(N);
  long long all = 0;
  for (int i = 0; i < N; i++) cin >> dq[i];
  for (int i = 0; i < N; i++) {
    if (i) pre[i] = pre[i - 1];
    pre[i] += dq[i];
  }
  for (int i = 0; i < N; i++) all += dq[i];
  sort(dq.begin(), dq.end());
  long long ans = all;
  while (dq.size() != 1) {
    ans += (long long)all;
    all -= (long long)dq[0];
    dq.pop_front();
  }
  cout << ans;
  return 0;
}
