const processData = (lines) => {
    const n = lines[1].split(' ').map(x => +x).sort((a, b) => b - a)

    let comfy = n[0]
    for (let i=1;i<n.length - 1; i++) {
        comfy += n[1 + Math.floor(i-1/2)]
    }

    console.log(comfy)
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
    const {EOL} = require('os')
    const lines = i.split(EOL) /*your input text, split by lines*/
    processData(lines)
})
