#include <cstdio>
#include <algorithm>

int main() {
	int arr[200003], n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &arr[i]);
	}
	std::sort(arr, arr + n, std::greater<int>());
	long long ans = 0;
	for (int i = 1; i < n; i++) {
		ans += arr[i / 2];
	}
	printf("%lld", ans);
	return 0;
}