fun main (args:Array<String>){
    val seqLen = readLine()!!.toInt()
    val seqList = mutableListOf<Int>()
    for(i in 1..seqLen){
        seqList.add(readLine()!!.toInt())
    }
    for(i in 0..seqLen-1){
        if(seqList[i] == seqList.max()){
            println(seqList.minus(seqList[i]).max())
        }
        else {
            println(seqList.max())
        }
    }
}