from itertools import combinations
import copy

n = int(input())
ls = [int(input()) for _ in range(n)]
p = 200000
ans = 0
if p>n:
    p=n

def cul(n, x):
    l = len(x)
    b = [x[i] for i in range(l)]
    b.pop(n)
    return max(b)
    
for i in range(p):
    s = cul(i,ls[:p])
    print(s)