import sys
n=int(sys.stdin.readline().strip())
inp=list(map(str,sys.stdin.readline().strip().split()))
appear=[-1]*1000000 #등장횟수
res=['-1' for _ in range(n)] #appear내 순서보다 크고 가장 왼쪽에 있는 수
for i in range(n) :
if (appear[int(inp[i])])==-1 :
appear[int(inp[i])]=inp.count(inp[i])
#print(appear)
for i in range(n) :
for j in range(i+1,n) : #이거 없애야하는데,,
if appear[int(inp[i])] < appear[int(inp[j])]:
res[i] = str(inp[j])
break
print(' '.join(res))