from sys import stdin
n = int(stdin.readline().rstrip())
li = list(int(stdin.readline().rstrip()) for _ in range(n))
one = max(li)
two = sorted(li)[-2]
for i in range(n):
    if max(li) == li[i]:
        print(two)
    else:
        print(max(one)