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


for i in range(n):
    if i > 0:
        mae = max(a[:i])
    else:
        mae = 0
        
    if i < n-1:
        ato = max(a[i+1:])
    else:
        ato = 0
    #print(mae, ato)
    print(max(mae, ato))