#include <bits/stdc++.h>
using namespace std;
const int N = 400001, oo = (1 << 29), Z = 501;
int n;
vector<long long> v;
vector<long long> vc;
set<long long> s;
int sz;
long long arr[N];
long long fre[N * 10];
long long calc(int i, int j) {
  if (i == j) return vc[i];
  return (long long)vc[i] + (long long)calc(i + 1, j) +
         (long long)(v[sz - 1] - ((i > 0) ? v[i - 1] : 0));
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%lld", arr + i);
    v.push_back(arr[i]);
    vc.push_back(arr[i]);
  }
  sz = v.size();
  sort(v.begin(), v.end());
  sort(vc.begin(), vc.end());
  for (int i = 1; i < sz; ++i) v[i] += v[i - 1];
  long long res = 0;
  for (int i = 0; i < sz; ++i) {
    if (i == sz - 1) {
      res += vc[i];
      break;
    }
    res += (vc[i] + v[sz - 1] - ((i == 0) ? 0 : v[i - 1]));
  }
  cout << res << endl;
  return 0;
}
