#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int a[n], s = 0, c = n - 1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  sort(a, a + n);
  reverse(a, a + n);
  for (int i = 0; i < n; i++) {
    if (i == 0 || i == 1)
      s += (c * a[i]);
    else {
      c--;
      s += (c * a[i]);
    }
  }
  cout << s;
  return 0;
}
