N = int(raw_input()) SA = [[0,i] for i in range(N)] ans = [-1 for i in range(N)] A = [int(raw_input()) for i in range(N)] for i in range(N): SA[A[i]][0] += 1 SA.sort(reverse = True) for num, idx in SA: for i in range(N): if ans[i] == -1 and A[i] != idx: ans[i] = idx break else: print -1 break else: for i in range(N): print ans[i]