n = int(input())
l = []
for i in range(n):
    l.append(int(input()))

max_a = max(l)

for j in range(len(l)):
    if max_a == l[j]:
        tmp = l.pop(j)
        print(max(l))
        l.insert(j, tmp)
    else:
        print(max_a)
