import copy

N = int(input())

A = [int(input()) for _ in range(N)]

max_a = max(A)

for i in range(N):
    max_l=0
    max_R=0
    if(A[:i]!=[]):
        max_l = max(A[:i])
    if(A[i+1:]!=[]):
        max_r = max(A[i+1:])
    print(max(max_r,max_l))
