#include <bits/stdc++.h>
using namespace std;
int i, n;
long long a[300005], rs;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; ++i) cin >> a[i];
  sort(a + 1, a + n + 1);
  for (i = n - 1; i; --i) a[i] += a[i + 1];
  for (i = 1, rs = a[1]; i < n; ++i) rs += a[i];
  cout << rs << '\n';
  return 0;
}
