function D173(_input) {
    var lines = _input.split("\n");
    var num = lines.shift()*1;
    var nums = lines[0].split(' ').map(v => v*1).sort((v1, v2) => v2 - v1);
    var result = 0;

    if (num === 2) {
        console.log(nums[0]);
        return;
    }

    let index = 0;
    let c = 1;

    for(let i = 0; i < num - 1; i++) {
        result+=nums[index];
        if (c % 2 === 1) {
            index++;
        }
        c++;
    }

    console.log(result);
}
D173(require("fs").readFileSync("/dev/stdin", "utf8"));
