import collections def read_data(): N = int(input()) As = [int(input()) for i in range(N)] return N, As def solve(N, As): if N == 1: return [-1] result = [-1] * N freq = collections.Counter([a for a in As if a < N]) free = [i for i in range(N) if i not in freq] most_com = freq.most_common() poss = [pos for pos, count in most_com] + free priority = [(freq[a], i, a) for i, a in enumerate(As)] priority.sort() for pos in poss: idx = len(priority) - 1 while priority[idx][2] == pos: idx -= 1 if idx < 0: return [-1] result[priority[idx][1]] = pos del priority[idx] return result N, As = read_data() answer = solve(N, As) for ans in answer: print(ans)