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

flag = {}
for i in range(n):
    if a[i] in flag:
        flag[a[i]] += 1
    else:
        flag[a[i]] = 1

for j in range(n):
    if flag[a[j]] > 1:
        flag[a[j]] -= 1
    else:
        flag.pop(a[j])
    
    print(max(flag))
    if a[j] in flag:
        flag[a[j]] += 1
    else:
        flag[a[j]] = 1