function Main(input) {
    input = input.trim().split('\n');
    const n = parseInt(input[0], 10);
    const a = input[1].split(' ').sort((a,b) => parseInt(b, 10) - parseInt(a, 10));
    const sum = a.reduce((acc, cur) => parseInt(acc, 10) + parseInt(cur, 10));
    console.log(sum - parseInt(a[a.length -1], 10));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));