var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var N = +o.getValue(0);
    var Ai = o.getArray(1);

    var sorted = Ai.sort(function (a, b) {
        return b - a;
    })

    var score = 0;
    for (let i = 0; i < N; i++) {
        var diff = i === 0 ? -1 : 0 - i % 2;
        var b = Math.ceil(i / 2);
        var index = i - (i - b - diff);
        if (sorted[index]) score += sorted[index];
    }

    return score;
}