"use strict"
function main(arg) {
    let N = arg.trim().split("\n")[0]
    N = Number(N)
    let data = arg.trim().split("\n")[1].split(" ").map(Number).sort((a,b) => b-a)
    let ans = data.reduce((a,b) => a+b) - data[data.length - 1]
    console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));