n=int(input())
a=list(int(input()) for i in range(n))
b=[0]
c=[0]
for i in range(n):
    b.append(max(a[:i+1]))
    c.append(max(a[n-i-1:]))
del b[n]
del c[n]

for i in range(n):
    d=b[i]
    e=c[n-1-i]
    print(max(d,e))