import copy
n = int(input())
a = [int(input()) for _ in range(n)]
m = max(a)

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