#include <bits/stdc++.h>
using namespace std;
long long int N;
long long int arr[300005];
int main() {
  long long int temp = 0, ans = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
    temp += arr[i];
  }
  sort(arr, arr + N);
  ans = temp;
  for (int i = 0; i < N; i++) {
    temp -= arr[i];
    ans += arr[i] + temp;
  }
  ans -= arr[N - 1];
  cout << ans << endl;
}
