
function Main(input) {
  var N = parseInt(input[0], 10);
  var A = input.slice(1).map(a => parseInt(a, 10));
  var orgA = A.map(a => a);

  var sortedA = A.sort((a, b) => b - a);

  for (var i = 0; i < N; i++) {
    if (orgA[i] === sortedA[0]) {
      console.log(sortedA[1]);
    } else {
      console.log(sortedA[0]);
    }
  }

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));