#include <bits/stdc++.h>
using namespace std;


#define ll long long
#define ld long double
#define ull unsigned long long
#define vi vector<ll>
#define pii pair<ll,ll>
#define vii vector<pii>
#define mp make_pair
#define pb push_back
#define rep(n) for(long i=0;i<n;i++)
#define fori(i,a,b) for(auto i=a;i<=b;i++)
#define ford(i,b,a) for(auto i=b;i>=a;i--)
#define mset(a,i) memset(a,i,sizeof(a))
#define maxheap(v) priority_queue<v>
#define minheap(v) priority_queue<v, vector<v>, greater<v>>
#define ff first
#define ss second
#define endl "\n"
#define NL cout<<endl;
#define all(v) v.begin(),v.end()
#define len(s) (ll)(s.length())
#define sz(v) (ll)(v.size())
#define fast_io() cin.sync_with_stdio(false);cout.sync_with_stdio(false);cin.tie(NULL);
#define tests ll testcases;cin>>testcases;while(testcases--)
#define PI 3.1415926535
#define mod (ll)(1e9+7)
#define mod2 998244353

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for (auto v : V) os << v << " ";
    return os << "]";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for (auto s : S) os << s << " ";
    return os << "}";
}
template<class T> ostream& operator<<(ostream &os, unordered_set<T> S) {
    os << "{ ";
    for (auto s : S) os << s << " ";
    return os << "}";
}
template<class T> ostream& operator << (ostream& os, multiset<T> S) {
    os << "{ ";
    for (auto s : S) os << s << " ";
    return os << "}";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.first << "," << P.second << ")";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for (auto m : M) os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}
template<class L, class R, class chash = std::hash<R>> ostream & operator<<(ostream &os, unordered_map<L, R, chash> M) {
    os << "{ ";
    for (auto m : M) os << "(" << m.first << ":" << m.second << ") ";
    return os << "}";
}

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

inline ll sbt(ll x) {return __builtin_popcountll(x); }
inline ll iceil(ld a) { return (ll)(ceil(a)); }
inline ll abceil(ll a, ll b) { return (a + b - 1) / b; }

inline ll mul(ll a, ll b, ll m = mod) { return ((a % m) * (b % m)) % m; }
inline ll add(ll a, ll b, ll m = mod) { return (a + b) % m; }
inline ll sub(ll a, ll b, ll m = mod) { return (a - b + m) % m; }

ll fastpow(ll a, ll b, ll m = mod) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = mul(res, a, m);
        a = mul(a, a, m);
        b >>= 1;
    }
    return res;
}

// Works when m is prime - Fermat's little theorem
ll modinv(ll a, ll m = mod) {
    return fastpow(a, m - 2, m);
}


// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val


void get_ac() {
    ll n, s = 0;
    cin >> n;
    ll a[n], b[n];
    rep(n) {
        cin >> a[i];
    }
    sort(a, a + n, greater<ll>());
    s = a[0];
    int j = 2;
    if (n == 2) {
        cout << s;
        return;
    }
    fori(i, 1, n - 1) {
        if (j + 2 <= n) {
            s += 2 * a[i];
            j += 2;
        }
        else {
            s += a[i];
            j++;
        }
        if (j == n) break;
    }
    cout << s;
}

int main() {
    fast_io()

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    // tests
    {
        get_ac();
        NL
    }

    return 0;
}

Measured memory_bytes: 5216