fun main(args: Array<String>) {
    val n = readInt()
    val a = List(n) { readInt() }

    for (i in 0 until n) {
        println(a.filterIndexed { index, _ -> index != i }.max())
    }
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()