#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a, a + n, greater<int>());
	int cnt = 0;
	long long scoa = 0;
	while (cnt < n - 1) {
		cnt++;
		scoa += a[cnt / 2];
	}
	cout << scoa << endl;
}