import java.util.*

fun main(args: Array<String>) {
    val argList = Scanner(System.`in`)


    val n = argList.nextLine().toInt()
    val a = mutableListOf<Int>()

    while (argList.hasNext()) {
        a.add(argList.nextLine().toInt())
    }

    val e = ExceptionHandling()
    e.execute(n, a)

}

class ExceptionHandling {
    fun execute(n: Int, a: List<Int>) {

        a.forEachIndexed { index, i ->
            val exceptedA = a.filterIndexed { ia, ai -> ia != index }
            println(exceptedA.max())
        }
    }
}