n = int(input())
a = [int(input()) for i in range(n)]
max_a = max(a)
for i in range(len(a)):
    if a[i] != max_a:
        print(max_a)
        continue
    if a.count(a[i]) > 1:
        print(max_a)
        continue
    b = a.copy()
    del b[i]
    print(max(b))