function Main(input) {
	input = input.split("\n");
	tmp = input[1].split(" ");
	
	
	var n = parseInt(input[0], 10);
	var a = [];
	
	for (var i = 0; i < n; i++) {
	a.push(parseInt(tmp[i], 10));
	}
	
	a.sort(
	function(a,b){
    	return (a < b ? 1 : -1);
	}
	);
	
	var x = 0;
	var y = 0;
	var result = a[0];
	for (var i = 1; i < n - 1; i++) {
	x = a[i];
	y = a[i + 1];
	
	if  (x > y) {
	result = result + x;
	} else {
	result = result + y;
	}
	}
	
	console.log(result);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));