import java.util.*

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

    (0..n).forEach { i ->
        val tmpList = aList.toMutableList()
        tmpList.removeAt(i)
        println(tmpList.max())
    }
}