'use strict'
const main = input => {
  const n = parseInt(input[0], 10)
  input.shift();
  const a = input.map(val => parseInt(val, 10));
  a.pop();
  // console.log(n, a);
  const arr = [...a];
  a.sort((x,y) => y-x);
  // console.log(a);
  for(let i=0; i<n; i++) {
    console.log(arr[i]==a[0]?a[1]:a[0]);
  }
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));