function Main(input) {

	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    input.shift();
    
    let A = input[0].split(" ").map(value => BigInt(value));
    A.sort((a, b) => (a < b) ? 1 : ((a > b) ? -1 : 0));
    
    let sum = A.reduce((acm, cur) => acm + cur);
    sum -= A[A.length - 1];
 
    console.log(String(sum));
    
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));