N = int(input())
li = []
for _ in range(N):
    li.append(int(input()))
    
for i in range(N):
    if i != 0:
        a = max(li[:i])
    else:
        a = 0
    
    if i != N-1:
        b = max(li[i+1:])
    else:
        b = 0
    print(max([a,b]))