n = int(input())
a = [int(input()) for _ in range(n)]
for i in range(n):
    if max(a) == a[i]:
        if len(set(a)) == 1:
            print(max(a))
        else:
            k = sorted(set(a))
            print(k[-2])
    else:
        print(max(a))