fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val A = Array(N) {
        readLine()!!.toInt()
    }

    for (i in A.indices) {
        A.filterIndexed { index, e -> i != index }.max().let(::println)
    }
}

