object Main extends App {
  val n = io.StdIn.readInt
  val as = (1 to n).map{ _ => io.StdIn.readInt }
  (1 to n)
    .foreach(i => {
      val mx = as.zipWithIndex
        .filter { case (_, ix) => (ix + 1) != i }
        .map{ case (a, _) => a }
        .max
      println(mx)
    })
}
