#include <bits/stdc++.h>
using namespace std;
int n;
long long a[300005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%I64d", &a[i]);
  sort(a, a + n);
  for (int i = n - 2; i >= 0; i--) a[i] += a[i + 1];
  long long sum = a[0];
  for (int i = 0; i <= n - 2; i++) sum += a[i];
  cout << sum << endl;
  return 0;
}
