n = int(input())
ll = [[] for _ in range(n+1)]

count = 1
for i in range(n):
    ll[0].append(int(input()))
    ll[count] = ll[0].copy()
    ll[count][count-1] = 0
    max = 0
    for j in ll[count]:
        if j>max:
            max = j
        else:
            pass
    print(max)
    count+=1
