import java.util.*

fun main(args: Array<String>) {
    try {
        val sc = Scanner(System.`in`)
        val n = sc.nextInt()
        if (n < 2 || n > 200000) {
            throw Exception("Unexpected input.")
        }
        val a = IntArray(n)
        for (i in 0 until n) {
            a[i] = sc.nextInt()
        }
        for (i in 0 until n) {
            val b = a.copyOf()
            b[i] = 0
            b.sort()
            println(b.max())
        }
    } catch (e: Exception) {
        println(e)
    }
}