'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)
	const a = args.slice(1, n + 1).map(arg => parseInt(arg[0], 10))
	const sortedA = a.slice().sort((t1, t2) => t2 - t1)

	for (let i = 0; i < n; i++) {
		if (a[i] !== sortedA[0]) console.log(sortedA[0])
		else console.log(sortedA[1])
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
