const input = require('fs').readFileSync('/dev/stdin','utf8')
                           .split("\n")
                           .map(i => Number(i))
const N = input[1]
const A = input.slice(2,input.length-1)

for(var i = 0;i<N;i++) {
    const lst = A.slice(0,i).concat(A.slice(i+1,A.length))
    console.log(Math.max(...lst))
}