n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))

for j in range(n):
    tmp = a[j]
    if max(a) == tmp:
        a[j] = 0
        print(max(a))
        a[j] = tmp
    else:
        print(max(a))