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