fun main(args: Array<String>) {
    val aArray = IntArray(readLine()!!.toInt()) {
        readLine()!!.toInt()
    }

    repeat(aArray.size) {
        val tempList = aArray.toMutableList()
        tempList.remove(aArray[it])
        println(tempList.max())
    }
}
