n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
for i in range(n):
    max1 = 0
    max2 = 0
    if a[:i] != []:
        max1 = max(a[:i])
    if a[i+1:] != []:
        max2 = max(a[i+1:])
    print(max(max1, max2))
