function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0][0], 10);
    var vec_A = input[1].map(e => parseInt(e, 10));
    vec_A.sort((a,b) => b - a);
    var count = 0;
    var ans = vec_A[0];
    if (N > 2){
        var tmpIndex;
        while (true){
            count ++;
            tmpIndex = Math.ceil(count / 2);
            ans += vec_A[tmpIndex];
            if (count === N - 2) break;
        }    
    }
    console.log(ans);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 