#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A.begin(), A.end(), greater<long long>());
	long long ans = 0;
	for (int i = 0; i < N - 1; i++) ans += A[(i+1) / 2];
	cout << ans << endl;
}