#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0, s = 0, s1 = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s += a[i];
  }
  sort(a, a + n, greater<int>());
  ans = s;
  for (int i = n - 1; i > 0; i--) {
    s1 += a[i];
    ans += (a[i] + (s - s1));
  }
  cout << ans;
}
