N = int(input())
num_array = []
for i in range(N):
   num_array.append(int(input()))

for i in range(N):
    a = 0
    b = 0
    if (i != 0):
        a = max(num_array[0:i])
    if (i+1 < N):
        b = max(num_array[i+1:N])
    if a > b: 
        print(a)
    else: 
        print(b)
    