n=int(input())
l=[]
k=[]
for i in range(n):
    a=int(input())
    l.append(a)
    k.append(a)
for i in range(n):
    if i==0:
        print(max(l[1:n]))
    elif i==n-1:
        print(max(l[0:n-1]))
    else:
        a=max(l[0:i])
        b=max(l[i+1:n])
        print(max(a,b))