import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextInt()
    val arr: Array<Int> = Array(n){sc.nextInt()}
    abc134c(n, arr)
}

fun abc134c(n: Int, arr: Array<Int>): Unit {
    for(i in 0 until n){
        val tmp = arr[i]
        arr[i] = 0
        println(arr.max())
        arr[i] = tmp
    }
}


fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }

