#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long;

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