n = int(input())
a = list(int(input()) for _ in range(n))

num = max(a)
for i in range(n):
    if a[i] < num:
        print(num)
    else:
        b = a.copy()
        int(b.pop(i))
        print(max(b))