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  = sorted(sortArr, reverse = True)

for x in range(len(intArr)):
    if(intArr[x] != sortArr[0] or len(sortArr)==1):
        print(sortArr[0])
    else:
        print(sortArr[1])