def calculate(arr):
    arr2 = rank(arr.copy())

    max = arr2[len(arr2) - 1]
    second = arr2[len(arr2) - 2]

    for i in range(len(arr)):
        value = arr[i]
        if max != value:
            print(max)
        else:
            print(second)



def rank(arr):
    lastIndex = len(arr) - 1
    while lastIndex > 0:

        for i in range(lastIndex):
            if arr[i + 1] < arr[i]:
                tmp = arr[i + 1]
                arr[i + 1] = arr[i]
                arr[i] = tmp

        lastIndex = lastIndex - 1

    return arr



N = int(input())
arr = []
for i in range(N):
    arr.append(int(input()))

calculate(arr)

