import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val list = mutableListOf<Int>()
    for(i in 0..n-1){
        list.add(scanner.nextInt())
    }
    for(i in 0..n-1) {
        val temp = mutableListOf<Int>()
        temp.addAll(list)
        temp.removeAt(i)
        println(temp.max())
    }
}