#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long int
#define pll pair<ll,ll>
#define pii pair<int,int>
#include<limits>
// #define deb(x) cout<<#x<<'='<<(x)<<endl
// #define deb2(x,y) cout<<'['<<#x<<'='<<(x)<<','<<#y<<'='<<(y)<<']'<<endl
#define debarr(a,n) {cout<<#a<<" = "; for(int i=0;i<n;i++) cout << a[i] << " \n"[i==n-1];}
#define debvec(v) {cout<<#v<<" = ";for(auto itr=v.begin();itr!=v.end();itr++)cout<<*itr<<' ';cout<<endl;}
#define INF numeric_limits<int>::max()
#define NINF numeric_limits<int>::min()
#define endl "\n"
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define MOD (ll)(pow(10,9)+7)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define vi vector<int>
#define vl vector<long long>
#define vvi vector<vi>
#define vvl vector<vl>
#define all(a) a.begin(),a.end()
#define umap unordered_map
#define uset unordered_set
#define deci(n) cout<<fixed<<setprecision(n)
#define pq priority_queue
#define mt make_tuple
#define eb emplace_back
#define fo(i,a,b) for(ll i=a;i<b;i++)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
using namespace std;
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

// void err(istream_iterator<string> it) {}
// template<typename T, typename... Args>
// void err(istream_iterator<string> it, T a, Args... args) {
// 	cerr << *it << " = " << a << endl;
// 	err(++it, args...);
// }

void boost() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

template<typename T,typename U>inline bool exist(T cont,U val){return cont.find(val)!=cont.end();}
template<typename T>bool isPrime(T n){for(T i=2;i*i<=n;i++)if(n%i==0)return 0;return 1;}
template<typename T>inline bool in_range(T a,T l,T r){return (a>=l&&a<=r);}

template <class I1, class I2>
bool have_common_element(I1 first1, I1 last1, I2 first2, I2 last2) {
    while (first1 != last1 && first2 != last2) {
        if (*first1 < *first2)
            ++first1;
        else if (*first2 < *first1)
            ++first2;
        else
            return true;
    }
    return false;
}
struct myhash
{
    static uint64_t fxn(uint64_t x)
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator ()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return fxn(x + FIXED_RANDOM);
    }
};

// struct hash_pair { 
//     template <class T1, class T2> 
//     size_t operator()(const pair<T1, T2>& p) const
//     { 
//         auto hash1 = hash<T1>{}(p.first); 
//         auto hash2 = hash<T2>{}(p.second); 
//         return hash1 ^ hash2; 
//     } 
// };
// umap<pair<ll, ll>, bool, hash_pair> um;

int Sum() { return 0; }
template<typename T, typename... Args>
T Sum(T a, Args... args) { return a + Sum(args...); }


ll mod(ll n,ll a)
{
    string num = to_string(n);
    ll res= 0;
    for(ll i=0;i<(ll)num.length();i++)
    {
        res=(res*10+(ll)num[i]-'0')%a;
    }
    return res;
}

ll ncrmodp(ll num,ll r)
{
    ll C[r+1];
    ll i,j;
    memset(C,0,sizeof(C));
    C[0]=1;
    for(i=1;i<=num;i++)
    {
        for(j=min(i,r);j>0;j--)
        {
            C[j]=((C[j])%MOD+(C[j-1])%MOD)%MOD;
        }
    }
    return C[r];
}

ll pw(ll x, ll n){
    ll ans=1;
    while(n){
        if(n&1ll){
            ans*=x;
            // ans%=mod;
        }
        x*=x;
        // x%=mod;
        n>>=1ll;
    }
    return ans;
}
bool isPowerOfTwo(ll n) 
{ 
   if(n==0) 
   return false; 
  
   return (ceil(log2(n)) == floor(log2(n))); 
}

bool isPrime(ll n) 
{ 
    if(n<=1) 
        return false; 
    if(n<=3) 
        return true; 
    if (n%2 == 0 || n%3 == 0) 
        return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
            return false; 
    return true; 
} 

int main()
{
    boost();
    ll tc=1;
    // cin>>tc;
    while(tc--)
    {
        ll n;
        cin>>n;
        vl v(n);
        fo(i,0,n)cin>>v[i];
        sort(all(v),greater<ll>());
        ll ans =v[0];
        ll t =1;
        ll ind =1;
        while(t<n-1)
        {
            if(t<=n-3)
            {
                ans+=v[ind]*2;
                t+=2;
                ind++;
            }
            else
            {
                ans+=v[ind];
                t++;
                ind++;
                
            }
            // deb(t,ans);
        }
        cout<<ans<<endl;


    }
    return 0;
}

Measured memory_bytes: 4784