const input = require('fs').readFileSync('/dev/stdin','utf8')
                           .split("\n")
                           .map(i => Number(i))
const N = input[0]
const A = input.slice(1,input.length-1)
for(var i = 0;i<N;i++) {
    if(Math.max(...A) === A[i]) {
        const lst = A.slice(0,i).concat(A.slice(i+1,A.length))
        console.log(Math.max(...lst))

    }else{
        console.log(Math.max(...A))
    }
}