function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const As = input.slice(1).map(x => parseInt(x))

	for(i=0; i < As.length; i++){
		var filter = As.filter((e, id) => id != i )
		filter.sort((a,b) => b-a)
		console.log(filter[0])
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));