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 < N; i++){
		var max = 0
		As.forEach((e, id) => {
			if(id != i && e > max) max = e
		})
		console.log(max)
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));