#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j;
  long long sum = 0, cnt, ans, v = 0, arr[300005];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    sum += arr[i];
  }
  sort(arr, arr + n);
  if (n == 1)
    cout << arr[0] << "\n";
  else if (n == 2)
    cout << 2 * sum << "\n";
  else {
    ans = arr[0];
    for (j = 1; j < n; j++) {
      arr[j] += arr[j - 1];
      ans += arr[j];
    }
    ans = ans - (arr[n - 1] + arr[n - 2]);
    cout << (n * sum) - ans << "\n";
  }
  return 0;
}
