n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(list(set(a)))

if len(b) == 1:
    for i in range(n):
        print(b[0])
    exit()

for i in a:
    if i == b[-1]:
        print(b[-2])
    else:
        print(b[-1])