input = require('fs').readFileSync('/dev/stdin', 'utf8')  
lines = input.split('\n')
N = lines.shift() * 1
arr = lines.map((a) => a * 1)
arr.sort((a,b) => b - a)
for (i=0; i<N; i++) {
    console.log(lines[i] == arr[0] ? arr[1] : arr[0])
}