object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val a = Seq.fill(n)(sc.nextInt)

  for (i <- (0 to n - 1)) {
    val tmp = a.splitAt(i)
    println((tmp._1 ++ tmp._2.tail).max)
  }
}
