import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextInt() }.toIntArray()

  val array = Array(n) { Array(n) { a[it] } }

  val ans = mutableListOf<Int>()
  for (i in 0 until n) {
    array[i][i] = 0
    val max = array[i].max()!!
    ans.add(max)
  }

  println(ans.joinToString("\n"))
}
