inNum = int(input())
intArr = []

sortArr = []
while(inNum > 0):
    tempNum =int(input())
    intArr.append(tempNum)
    inNum = inNum-1
    if(not tempNum in sortArr):
        sortArr.append(tempNum)
sortArr.sort()
sortArr.reverse()

for x in intArr:
    if(not x == sortArr[0]):
        print(sortArr[0])
    if(x == sortArr[0]):
        print(sortArr[1])