#include<bits/stdc++.h>
#define ll long long 
using namespace std;
int a[200005];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;++i)
	cin>>a[i];
	sort(a+1,a+n+1);
	ll sum=a[n];int num=n-2,t=0,x=n-1;
	while(num--)
	{
		sum+=a[x];
		t++;
		if(t==2)
		{
			t=0;
			x--;
		}
	}
	cout<<sum;
 } 