n = int(input())
a = [input() for i in range(n)]
for i in range(n-1):
    if i==0:
        print(max(a[1:]))
    else:
        max1 = max(a[:i])
        max2 = max(a[i+1:])
        print(max(max1, max2))
print(max(a[:n]))
