const { SSL_OP_SSLEAY_080_CLIENT_DH_BUG } = require("constants");

/**
 * main処理
 *
 * @param {*} lines
 */
const main = async (lines) => {
    let n;
    const a = [];

    // 以下読み取り
    for (let i = 0; i < lines.length; i++) {
        v = lines[i];

        if (v != "") { // 入力のある行のみ読み込む

            // 0行目でnの読み取り
            if (i == 0) {
                n = v;
            }

            if (i == 1) {
                const inputs = v.split(" ");
                for (let j = 0; j < inputs.length; j++) {
                    a[j] = Number(inputs[j]);
                }
                a.sort((a, b) => {
                    if (a > b) return -1;
                    if (a < b) return 1;
                    return 0;
                });
            }

        }
    }

    let sum = 0;
    for (let i = 0; i < n - 1; i++) {
        if (i == 0) {
            sum += a[i];
        } else {
            const b = Math.floor((i + 1) / 2);
            sum += a[b];
        }
    }
    console.log(sum);
}

/**
 * 入力を読み取る
 *
 */
const runWithStdin = async () => {
    let input = "";
    process.stdin.resume();
    process.stdin.setEncoding("utf8");

    process.stdin.on("data", v => {
        input += v;
    });
    process.stdin.on("end", () => {
        main(input.split("\n"));
    });
}
runWithStdin();