#include<iostream>
#include<math.h>
using namespace std;
long long int MOD = 1000000007;
long long int A[200000];
void margesort(long long int a[], long long int a_len, long long int left, long long int right);
long long int temp[200000];
long long modpow(long long a, long long n, long long mod);
long long modinv(long long a, long long mod);
int main() {

	//D
	int n;
	int i;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}
	margesort(A, n, 0, n - 1);
	long long int S = 0;
	for (i = 2; i <= n; i++) {
		S = S + A[n - (i + 1 - ((i + 1) % 2)) / 2];
	}
	cout << S << endl;
	return 0;

	//E

	/*int i,n,k;
	cin >> n >> k;
	int mincounter = 0;
	for (i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] <= 0) {
			mincounter++;
		}
	}
	margesort(A, n, 0, n - 1);
	long long int res = 1;
	int flag1 = 0, flag2 = 0, flag3 = 0, flag4 = 0;
	long long int minminus, minplus, maxminus, maxplus;
	if (k == n) {

		for (i = 0; i < n; i++) {
			res = (res * (A[i] + MOD)) % MOD;
		}
		cout << res << endl;
		return 0;

	}
	else if ((mincounter == n) && ((k % 2) == 1)) {
		for (i = 0; i < k; i++) {
			res = (res * (A[i] + MOD)) % MOD;
		}
		cout << res << endl;
		return 0;
	}
	else if (A[n - k] == 0) {
		cout << 0 << endl;
		return 0;
	}else{
		mincounter = 0;
		for (i = 1; i <= k; i++) {
			res = (res * (A[n - i] + MOD)) % MOD;
			if (A[n - i] < 0)mincounter++;
		}
		if ((mincounter % 2) == 1) {

			for (i = k + 1; i <= n; i++) {
				if (A[n - i] > 0) {
					maxplus = A[n - i];
					flag1 = 1;
					break;
				}
			}
			
			for (i = k + 1; i <= n; i++) {
				if (A[n - i] < 0) {
					maxminus = A[n - i];
					flag2 = 1;
					break;
				}
			}

			for (i = k; i > 0; i--) {
				if (A[n - i] > 0) {
					minplus = A[n - i];
					flag3 = 1;
					break;
				}
			}

			for (i = k; i > 0; i--) {
				if (A[n - i] < 0) {
					minminus = A[n - i];
					flag4 = 1;
					break;
				}
			}

			res = (res * (MOD - 1)) % MOD;
			
			if ((flag1 == 1) && (flag4 == 1)) {
				if ((flag2 == 1) && (flag3 == 1)) {
					if (abs(maxplus * minplus) > abs(maxminus * minminus)) {
						res = (res * modinv(abs(minminus), MOD)) % MOD;
						res = (res * maxplus) % MOD;
					}
					else {
						res = (res * modinv(minplus, MOD)) % MOD;
						res = (res * abs(maxminus)) % MOD;
					}
				}
				else {
					res = (res * modinv(abs(minminus), MOD)) % MOD;
					res = (res * maxplus) % MOD;
				}
			}
			else {
				res = (res * modinv(minplus, MOD)) % MOD;
				res = (res * abs(maxminus)) % MOD;
			}
			cout << res << endl;
			return 0;

		}
		else {
			cout << res << endl;
			return 0;
		}
	}
	//cout << ((-36 + MOD) * (3 + MOD)) % MOD << endl;
	return 0;
	
	*/

}

void margesort(long long int a[], long long int a_len, long long int left, long long int right)
{
	long long int i, j, mid, L, R;

	if (right <= left)
		return;

	mid = (left + right) / 2;
	margesort(a, mid, left, mid);
	margesort(a, a_len - mid, mid + 1, right);

	for (i = left; i <= mid; i++)
		temp[i] = a[i];
	for (i = mid + 1, j = right; i <= right; i++, j--)
		temp[i] = a[j];

	L = left;
	R = right;

	for (i = left; i <= right; i++)
	{
		if (abs(temp[L]) <= abs(temp[R]))
		{
			a[i] = temp[L];
			L++;
		}
		else
		{
			a[i] = temp[R];
			R--;
		}
	}
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
	return modpow(a, mod - 2, mod);
}


Measured memory_bytes: 6752