object Main extends App {
  val n = io.StdIn.readInt
  val as = for (_ <- 1 to n) yield io.StdIn.readInt
  
  for (count <- 0 until n) {
    val deleted = as.take(count) ++ as.drop(count).tail
    println(deleted.max)
  }
}