n = int(input())

li = [int(input()) for i in range(n)]

for i in range(n):
    if(i != 0):
        p1 = max(li[0:i])
    else:
        p1 = 0
    if(i != n-1):
        p2 = max(li[i+1:n])
    else:
        p2 = 0
    
    #print("{}, {}, {}".format(p1,p2,max(p1,p2)))
    print(max(p1,p2))