n = int(input())

a = [input() for i in range(n)]

print(max(a[1:]))

for i in range(1, n-1):
    a1 = max(a[:i])
    a2 = max(a[i+1:])
    max_a = a1 if a1 > a2 else a2
    print(max_a)
    
print(max(a[:-1]))