N=int(input())
a=[int(input()) for i in range(N) ]
maxR=0
maxL=0
for j in range(N):
    for k in range(j):
        maxL=max(maxL,a[k])
    for l in range(j+1,N):
        maxR=max(maxR,a[l])
    print(max(maxL,maxR))