object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N = sc.nextInt
  val zippedNumbers = List.fill(N)(sc.nextInt).zipWithIndex

  zippedNumbers.foreach((x) => println(zippedNumbers.filter((y) => y._2 != x._2)
  .map(z => z._1).max))
}