function main(lines) {
  const N = +lines[0];
  const as = splitN(lines[1]).sort((a, b) => b-a);
  
  as.pop();
  const res = as.reduce((acc, v) => {
    return acc+v;
  }, 0);
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}
