fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val numbers = mutableListOf<Int>()
    for (i in 0 until n) {
        numbers.add(readLine()!!.toInt())
    }

    for (i in 0 until n) {
        val subset = numbers.filterIndexed { index, number ->  index != i}
        println(subset.fold(initial = 0, operation = { a, b -> Math.max(a,b)}))
    }
}