Companies always have a lot of equipment, furniture and other things. All of them should be tracked. To do this, there is an inventory number assigned with each item. It is much easier to create a database by using those numbers and keep the track of everything.

During an audit, you were surprised to find out that the items are not numbered sequentially, and some items even share the same inventory number! There is an urgent need to fix it. You have chosen to make the numbers of the items sequential, starting with 1. Changing a number is quite a time-consuming process, and you would like to make maximum use of the current numbering.

You have been given information on current inventory numbers for n items in the company. Renumber items so that their inventory numbers form a permutation of numbers from 1 to n by changing the number of as few items as possible. Let us remind you that a set of n numbers forms a permutation if all the numbers are in the range from 1 to n, and no two numbers are equal.


-----Input-----

The first line contains a single integer n — the number of items (1 ≤ n ≤ 10^5).

The second line contains n numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5) — the initial inventory numbers of the items.


-----Output-----

Print n numbers — the final inventory numbers of the items in the order they occur in the input. If there are multiple possible answers, you may print any of them.


-----Examples-----
Input
3
1 3 2

Output
1 3 2 

Input
4
2 2 3 3

Output
2 1 3 4 

Input
1
2

Output
1 



-----Note-----

In the first test the numeration is already a permutation, so there is no need to change anything.

In the second test there are two pairs of equal numbers, in each pair you need to replace one number.

In the third test you need to replace 2 by 1, as the numbering should start from one.

Difficulty: EASY

Solutions:
n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(1, n + 1):
	d[i] = 0
p = []
for i in range(len(a)):
	if a[i] > n:
		p.append(i)
	elif d[a[i]] >= 1:
		p.append(i)
	else:
		d[a[i]] += 1
c = {}
for i in range(1, n + 1):
	c[i] = 0
for i in range(len(a)):
	if a[i] <= n:
		c[a[i]] += 1
o = []
for key in c:
	if c[key] == 0:
		o.append(key)
index = 0
for i in range(len(p)):
	a[p[i]] = o[index]
	index += 1
print(*a)


from collections import defaultdict
n = int(input())
a = [int(i) for i in input().split()]
d = defaultdict(int)
for i in a:
	d[i] += 1
np = []
for i in range(1, n + 1):
	if d[i] == 0:
		np.append(i)
s = set()
curr = 0
for i in range(n):
	if a[i] <= n and a[i] not in s:
		s.add(a[i])
	else:
		a[i] = np[curr]
		curr += 1
print(*a)


n = int(input())
lst = list(map(int, input().split()))
mn = set()
ans = set()
sp = []
for i in range(1, n + 1):
	mn.add(i)
for i in lst:
	if i in mn:
		mn.remove(i)
for i in lst:
	if i in ans or i > n:
		a = mn.pop()
		ans.add(a)
		sp.append(a)
	if i not in ans and i <= n:
		ans.add(i)
		sp.append(i)
print(*sp)


(n, a) = (int(input()), list(map(int, input().split())))
(d, r) = (set(range(1, n + 1)), [])
for (i, x) in enumerate(a):
	if x not in d:
		r.append(i)
	d.discard(x)
for x in r:
	a[x] = d.pop()
print(' '.join(map(str, a)))


from sys import stdin
from sys import stdout
n = int(stdin.readline())
an = list(map(int, stdin.readline().split()))
k = [0] * n
tp = []
ztp = []
for i in range(0, n):
	if an[i] <= n and k[an[i] - 1] == 0:
		k[an[i] - 1] = 1
	else:
		tp.append(i)
f = 0
for j in tp:
	while f < n:
		if k[f] == 0:
			an[j] = f + 1
			f += 1
			break
		else:
			f += 1
print(' '.join([str(x) for x in an]))


from collections import Counter
n = int(input())
a = list(map(int, input().rstrip().split()))
c = Counter((i for i in range(1, n + 1)))
inp = Counter(a)
c.subtract(inp)
c += Counter()
ans = []
for x in a:
	if inp[x] == -1 or x > n:
		for y in c:
			ans += [y]
			del c[y]
			break
	else:
		ans += [x]
		inp[x] = -1
print(*ans)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def f():
	sys.stdout.flush()

def solve():
	n = ii()
	a = li()
	m = {}
	x = []
	for i in range(n):
		if a[i] in m or a[i] > n:
			x.append(i)
			continue
		m[a[i]] = 1
	y = []
	for i in range(1, n + 1):
		if i not in m:
			y.append(i)
	for i in range(len(x)):
		ind = x[i]
		val = y[i]
		a[ind] = val
	print(*a)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


n = int(input())
inventory = [*map(int, input().split())]
bool = [False] * 100001
indices = set()
for (index, i) in enumerate(inventory):
	if i > n or bool[i]:
		indices.add(index)
	bool[i] = True
for i in range(1, n + 1):
	if not bool[i]:
		x = indices.pop()
		inventory[x] = i
print(' '.join([*map(str, inventory)]))


import sys
n = int(sys.stdin.readline())
a = sys.stdin.readline()

def writeAllNumbers(n, a):
	a = a.strip().split()
	a = [int(x) for x in a]
	posNeedChange = []
	exists = [0] * (10 ** 5 + 1)
	for pos in range(len(a)):
		num = a[pos]
		if exists[num] == 1:
			posNeedChange.append(pos)
		else:
			if num > n:
				posNeedChange.append(pos)
			exists[num] = 1
	notExists = []
	for pos in range(1, n + 1):
		if exists[pos] == 0:
			notExists.append(pos)
	posInNotExists = 0
	for pos in posNeedChange:
		a[pos] = notExists[posInNotExists]
		posInNotExists += 1
	for num in a:
		print(num, end=' ')
writeAllNumbers(n, a)


n = int(input())
ar = list(map(int, input().split()))
ar1 = set(range(1, n + 1))
ar2 = []
for i in ar:
	if i in ar1:
		ar1.remove(i)
		ar2.append(i)
	else:
		ar2.append(0)
for i in ar2:
	if i == 0:
		print(ar1.pop(), end=' ')
	else:
		print(i, end=' ')


__author__ = 'Алексей'
n = int(input())
numbers = set(range(1, n + 1))
answer = []
for x in map(int, input().split()):
	if x in numbers:
		numbers.remove(x)
		answer.append(x)
	else:
		answer.append(None)
for i in range(n):
	if answer[i] is None:
		answer[i] = numbers.pop()
print(' '.join(map(str, answer)))


n = int(input())
inventory = [*map(int, input().split())]
bool = [False] * (n + 1)
bads = set()
for (index, thing) in enumerate(inventory):
	if thing <= n:
		if bool[thing]:
			bads.add(index)
		else:
			bool[thing] = True
	else:
		bads.add(index)
for (num, isin) in enumerate(bool[1:]):
	if not isin and len(bads):
		i = bads.pop()
		inventory[i] = num + 1
		bool[num] = True
print(' '.join([*map(str, inventory)]))


n = int(input())
unseen = set(range(1, n + 1))
seen = set()
a = [int(x) for x in input().split()]
for x in a:
	unseen.discard(x)
for i in range(len(a)):
	if a[i] in seen or a[i] < 1 or a[i] > n:
		a[i] = unseen.pop()
	seen.add(a[i])
print(*a)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
n = mint()
a = list(mints())
ok = [True] * n
cnt = [0] * (10 ** 5 + 1)
for i in range(len(a)):
	x = a[i]
	if x <= n and cnt[x] == 0:
		ok[i] = False
		cnt[x] += 1
j = 1
r = 0
for i in range(len(a)):
	if ok[i]:
		while cnt[j] != 0:
			j += 1
		a[i] = j
		cnt[j] += 1
print(*a)


__author__ = 'Алексей'
n = int(input())
numbers = list(map(int, input().split()))
trash = []
mask = list(range(1, n + 1))
for i in range(n):
	if numbers[i] > n:
		trash.append(i)
	elif mask[numbers[i] - 1] == 0:
		trash.append(i)
	else:
		mask[numbers[i] - 1] = 0
j = 0
for i in trash:
	while mask[j] == 0:
		j += 1
	numbers[i] = j + 1
	j += 1
print(' '.join(map(str, numbers)))


def mp():
	return map(int, input().split())

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def printlist(l):
	print(' '.join([str(x) for x in l]))
n = it()
a = lt()
for i in range(n):
	a[i] -= 1
result = [-1 for i in range(n)]
deja = [False for i in range(n)]
t = 0
used = [False for i in range(n)]
for i in range(n):
	if a[i] <= n - 1 and (not deja[a[i]]):
		result[i] = a[i]
		deja[a[i]] = True
		used[i] = True
for i in range(n):
	if not used[i]:
		while deja[t]:
			t += 1
		result[i] = t
		t += 1
result = [result[i] + 1 for i in range(n)]
printlist(result)


from collections import deque as de
import math
import re
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def dupconscount(nums):
	element = []
	freque = []
	if not nums:
		return element
	running_count = 1
	for i in range(len(nums) - 1):
		if nums[i] == nums[i + 1]:
			running_count += 1
		else:
			freque.append(running_count)
			element.append(nums[i])
			running_count = 1
	freque.append(running_count)
	element.append(nums[i + 1])
	return (element, freque)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))
n = ii()
a = li()
dd = set(a)
if len(dd) == n and max(a) == n and (min(a) == 1):
	print(*a)
else:
	temp = set([i for i in range(1, n + 1)])
	not404 = list(temp - dd)
	verifire = {}
	j = 0
	for i in range(n):
		if a[i] not in verifire or a[i] > n:
			if a[i] > n:
				print(not404[j], end=' ')
				j += 1
			else:
				verifire[a[i]] = 1
				print(a[i], end=' ')
		else:
			print(not404[j], end=' ')
			j += 1


def read_list(t):
	return [t(x) for x in input().split()]

def read_line(t):
	return t(input())

def read_lines(t, N):
	return [t(input()) for _ in range(N)]
N = read_line(int)
A = read_list(int)
unused = list(set(range(1, N + 1)) - set(A))
cur = 0
used = [False] * (N + 1)
for (i, a) in enumerate(A):
	if a > N or used[a]:
		A[i] = unused[cur]
		used[A[i]] = True
		cur += 1
	else:
		used[a] = True
print(*A)


def main():
	n = int(input())
	a = [int(i) for i in input().split()]
	d = [0] * n
	for i in range(n):
		if a[i] > n or d[a[i] - 1] == 1:
			a[i] = -1
		else:
			d[a[i] - 1] = 1
	for s in range(n):
		if d[s] == 0:
			break
	for i in a:
		if i == -1:
			print(s + 1, end=' ')
			for s in range(s + 1, n):
				if d[s] == 0:
					break
		else:
			print(i, end=' ')
main()


(n, a) = (int(input()), list(map(int, input().split())))
usd = [False for i in range(n)]
got = [False for i in range(n)]
for i in range(n):
	if a[i] <= n and (not usd[a[i] - 1]):
		got[i] = usd[a[i] - 1] = True
nxt = 0
for i in range(n):
	if not got[i]:
		while usd[nxt]:
			nxt += 1
		a[i] = nxt + 1
		usd[nxt] = True
print(' '.join((str(x) for x in a)))


n = int(input())
used = (n + 1) * [False]
final = n * [None]
given = list(map(int, input().split()))
for (i, x) in enumerate(given):
	if x <= n and (not used[x]):
		final[i] = x
		used[x] = True
(used_pos, final_pos) = (0, 0)
(i, x) = (0, 1)
while i < n:
	if final[i] == None:
		while used[x]:
			x += 1
		final[i] = x
		x += 1
	i += 1
print(' '.join(map(str, final)))


def main():
	read = lambda : map(int, input().split())
	n = int(input())
	a = list(read())
	used = [True] * (n + 1)
	C = {i + 1 for i in range(n)}
	A = {i for i in a if i <= n}
	B = A ^ C
	for i in a:
		if i > n or not used[i]:
			print(B.pop(), end=' ')
		else:
			print(i, end=' ')
			used[i] = False
main()


import sys
n = int(sys.stdin.readline())
things = list(map(int, sys.stdin.readline().split()))
lastnum = 1
count = [0] * (n + 1)
for num in things:
	if num <= n:
		count[num] = 1
for num in things:
	if num > n or count[num] > 1:
		while count[lastnum]:
			lastnum += 1
		count[lastnum] = 1
		sys.stdout.write(str(lastnum) + ' ')
	else:
		count[num] = 2
		sys.stdout.write(str(num) + ' ')


import sys
a = int(input())
d = dict()
arr = list(map(int, input().split()))
for i in arr:
	d[i] = 1
s = set()
for i in range(1, a + 1):
	if i not in d:
		s.add(i)
d = dict()
for i in range(0, len(arr)):
	if arr[i] in d or arr[i] > a:
		arr[i] = s.pop()
	else:
		d[arr[i]] = 1
print(' '.join(map(str, arr)))


n = int(input())
things_numbers = list(map(int, input().split()))
things_numbers_set = set(things_numbers)
is_not_free = set()
j = 1
for i in range(0, n):
	if things_numbers[i] not in is_not_free and things_numbers[i] <= n:
		is_not_free.add(things_numbers[i])
	else:
		while j in things_numbers_set:
			j += 1
		things_numbers[i] = j
		j += 1
print(*things_numbers)


n = int(input())
A = [*map(int, input().split())]
X = set(range(1, n + 1)) - set(A)
used = set()
for a in A:
	if 0 < a <= n and a not in used:
		print(a, end=' ')
		used.add(a)
	else:
		print(X.pop(), end=' ')


def main():
	n = int(input()) + 1
	(res, fil, rest) = (list(map(int, input().split())), [True] * n, [])
	for (i, x) in enumerate(res):
		if x < n and fil[x]:
			fil[x] = False
		else:
			rest.append(i)
	for (i, x) in zip(rest, filter(fil.__getitem__, range(1, n))):
		res[i] = x
	print(' '.join(map(str, res)))
main()


n = int(input())
inp = list(map(int, input().split(' ')))
used = set(inp)
seen = set()
toadd = set((i + 1 for i in range(n) if i + 1 not in used))
res = []
for num in inp:
	if num < 1 or num > n or num in seen:
		num = toadd.pop()
	else:
		seen.add(num)
	res.append(num)
print(*res)


n = int(input())
lst = [int(x) for x in input().split()]
tmp = [False] * 100007
tmp2 = [False] * 100007
for x in lst:
	tmp[x] = True
(answer, index) = ([], 1)
for x in lst:
	if not tmp2[x] and x <= len(lst):
		answer.append(x)
		tmp2[x] = True
	else:
		while tmp[index]:
			index += 1
		tmp[index] = True
		answer.append(index)
print(' '.join(map(str, answer)))


n = int(input())
box = list(map(int, input().split()))
used = [False for i in range(n)]
accepted = [False for i in range(n)]
j = 0
for i in box:
	if i <= n and (not used[i - 1]):
		accepted[j] = True
		used[i - 1] = True
	j += 1
j = 0
for i in range(n):
	if not accepted[i]:
		while used[j] != False:
			j += 1
		j += 1
		print(j, end=' ')
	else:
		print(box[i], end=' ')


n = int(input())
array = list(map(int, input().split()))
answer = [0] * n
done = [False] * (n + 1)
for i in range(n):
	if 1 <= array[i] <= n and (not done[array[i]]):
		answer[i] = array[i]
		done[array[i]] = True
i = 1
for j in range(n):
	if answer[j] == 0:
		while done[i]:
			i += 1
		answer[j] = i
		i += 1
print(*answer)


n = int(input())
a = list(map(int, input().split()))
s = set(a)
k = set(range(1, n + 1))
need = k - s
vis = set()
for i in range(n):
	if a[i] in vis:
		a[i] = need.pop()
	elif a[i] not in k:
		a[i] = need.pop()
		vis.add(a[i])
	else:
		vis.add(a[i])
print(*a)


def solve(n, a):
	found = set(a)
	available = {i for i in range(1, n + 1) if i not in found}
	seen = set()
	for (i, v) in enumerate(a):
		if v in seen or v > n:
			nv = available.pop()
			a[i] = nv
		seen.add(a[i])
	return a
n = int(input())
a = list(map(int, input().split()))
print(*solve(n, a))


n = int(input())
a = list(map(int, input().split()))
s = set(a)
l = list(filter(lambda x: x not in s, [i for i in range(1, n + 1)]))
j = 0
for i in range(n):
	if 1 <= a[i] <= n and a[i] in s:
		s.remove(a[i])
	else:
		a[i] = l[j]
		j += 1
print(*a)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	used = set()
	original = set(a)
	not_used = set(range(1, n + 1)) - original
	for i in range(n):
		if a[i] > n or a[i] in used:
			temp = next(iter(not_used), None)
			if temp is not None:
				a[i] = temp
				not_used.remove(temp)
				used.add(temp)
		else:
			used.add(a[i])
	print(*a)
main()


n = int(input())
li = list(map(int, input().split()))
newset = set(range(1, n + 1))
s = []
for i in li:
	if i in newset:
		newset.remove(i)
		s.append(i)
	else:
		s.append(None)
for i in s:
	if i is None:
		print(newset.pop(), end=' ')
	else:
		print(i, end=' ')


n = int(input())
q = [int(x) for x in input().split()]
numbers = set(range(1, n + 1))
ans = []
for x in q:
	if x in numbers:
		numbers.remove(x)
		ans.append(x)
	else:
		ans.append(-999)
for x in ans:
	if x == -999:
		print(numbers.pop(), end=' ')
	else:
		print(x, end=' ')
print()


n = int(input())
a = [int(x) for x in input().strip().split()]
static_a = [0 for x in range(n)]
used = [0 for x in range(n + 1)]
for i in range(n):
	if a[i] <= n and used[a[i]] == 0:
		used[a[i]] = 1
		static_a[i] = 1
	else:
		continue

def next_unused():
	j = 1
	while used[j] != 0:
		j += 1
	while used[j] == 0 and j <= n:
		yield j
		used[j] = 1
		while used[j] != 0:
			j += 1
	return
nu = next_unused()
for i in range(n):
	if static_a[i] == 1:
		continue
	else:
		a[i] = next(nu)
for i in a:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
c = [0] * 100001
b = [0] * 100001
j = 1
for i in range(n):
	b[a[i]] = True
for i in range(n):
	if a[i] > n or c[a[i]]:
		while b[j]:
			j += 1
		b[j] = True
		c[j] = True
		print(j, end=' ')
	else:
		print(a[i], end=' ')
		c[a[i]] = True


from collections import defaultdict
n = int(input())
nums = list(map(int, input().split()))
d = defaultdict(int)
for num in nums:
	d[num] += 1
available = []
for i in range(1, n + 1):
	if d[i] > 0:
		continue
	available.append(i)
available.sort()
ia = 0
outs = []
processed = set()
for num in nums:
	if num > n or num < 1:
		print(available[ia], end=' ')
		ia += 1
	elif d[num] == 1:
		print(num, end=' ')
	elif d[num] == 0:
		print(available[ia], end=' ')
		ia += 1
	elif d[num] > 1:
		if num not in processed:
			print(num, end=' ')
			processed.add(num)
		else:
			print(available[ia], end=' ')
			ia += 1


n = int(input())
a = [int(i) for i in input().split()]
c = [0] * (n + 1)
for e in a:
	if e <= n:
		c[e] = 1
l = [e for e in range(1, n + 1) if c[e] == 0]
s = 0
c = [0] * (n + 1)
for i in range(n):
	if a[i] <= n and c[a[i]] < 1:
		c[a[i]] = 1
	else:
		a[i] = l[s]
		s += 1
for e in a:
	print(e, end=' ')


n = int(input())
s = list(map(int, input().split()))
f = [0] * n
for i in range(n):
	if s[i] > n:
		s[i] = 0
	elif f[s[i] - 1] == 0:
		f[s[i] - 1] = 1
	else:
		s[i] = 0
a = 0
for i in range(n):
	if s[i] == 0:
		while 1:
			if f[a] == 1:
				a += 1
			else:
				s[i] = a + 1
				a += 1
				break
print(' '.join(map(str, s)))


n = int(input())
l = list(map(int, input().split()))
ans = [0 for i in range(n)]
tmp = set(range(1, n + 1))
for (i, j) in enumerate(l):
	if j in tmp:
		ans[i] = j
		tmp.remove(j)
for (i, j) in enumerate(ans):
	if not ans[i]:
		ans[i] = tmp.pop()
print(*ans)


n = int(input())
fix = list()
factors = set(range(1, n + 1))
for i in map(int, input().split()):
	if i in factors:
		factors.remove(i)
		fix.append(i)
	else:
		fix.append(None)
print(' '.join((str(factors.pop()) if i is None else str(i) for i in fix)))


n = int(input())
a = input().split()
A = [0] * n
for i in range(n):
	if int(a[i]) <= n:
		if A[int(a[i]) - 1] == 0:
			A[int(a[i]) - 1] = 1
		else:
			a[i] = 'q'
	else:
		a[i] = 'q'
per = 0
l = 0
for i in range(n):
	if A[i] == 0:
		while per < n:
			if a[per] == 'q':
				a[per] = i + 1
				per += 1
				break
			else:
				per += 1
for i in a:
	print(i, end=' ')


def main():
	n = int(input())
	a = list(map(int, input().split()))
	used = [True] * (n + 1)
	X = {i + 1 for i in range(n)}
	Y = {i for i in a if i <= n}
	A = X ^ Y
	for i in a:
		if i > n or not used[i]:
			print(A.pop(), end=' ')
		else:
			used[i] = False
			print(i, end=' ')
main()


num = int(input())
list1 = input().split(' ')
inv = set()
for i in list1:
	inv.add(int(i))
missing = []
notE = []
for i in range(1, num + 1):
	if i not in inv:
		missing.append(i)
written = set()
j = 0
for i in range(len(list1)):
	if list1[i] in written or int(list1[i]) > num:
		list1[i] = str(missing[j])
		written.add(list1[i])
		j += 1
	else:
		written.add(list1[i])
print(*list1)


n = int(input())
inventory = input().split()
item_found = {str(x): False for x in range(1, n + 1)}
duplicate = set()
for (i, item) in enumerate(inventory):
	if int(item) > n or item_found[item]:
		duplicate.add(i)
	else:
		item_found[item] = True
for (i, item) in enumerate(item_found):
	if not item_found[item]:
		inventory[duplicate.pop()] = item
print(' '.join(inventory))


n = int(input())
a = [int(x) for x in input().split()]
p = [0] * n
s = set(range(1, n + 1))
for (i, x) in enumerate(a):
	if x in s:
		s.remove(x)
		p[i] = x
for (i, x) in enumerate(p):
	if not x:
		p[i] = s.pop()
print(' '.join(map(str, p)))


n = int(input())
inp = list(map(int, input().split(' ')))
used = set((x for x in inp if x > 0 and x <= n))
toadd = {i + 1 for i in range(n)}.difference(used)
res = []
for num in inp:
	if num in used:
		used.remove(num)
	else:
		num = toadd.pop()
	res.append(num)
print(*res)


n = int(input())
nums = list(map(int, input().strip().split(' ')))
snums = sorted(enumerate(nums), key=lambda x: x[1])
bonus = set()
holes = set()
skip = set()
count = 1
for (i, v) in snums:
	if v < count or v > n:
		bonus.add(i)
	if v == count:
		count += 1
	elif v > count:
		holes.update((j for j in range(min(n + 1, count), min(n + 1, v))))
		count = v + 1
while len(bonus) > 0 and len(holes) > 0:
	idx = bonus.pop()
	x = holes.pop()
	nums[idx] = x
	skip.add(idx)
if len(holes) == 0:
	last = snums[-1][1] + 1
	for i in bonus:
		nums[i] = last
		last += 1
else:
	assert len(bonus) == 0
	for (i, v) in snums[::-1]:
		if i in skip:
			continue
		if len(holes) == 0:
			break
		x = holes.pop()
		nums[i] = x
print(' '.join(map(lambda x: str(x), nums)))


n = int(input())
iv = [int(x) for x in input().split()]
(s, st) = (set(range(1, n + 1)), [])
for i in range(n):
	if iv[i] not in s:
		st.append(i)
	s.discard(iv[i])
for i in st:
	iv[i] = s.pop()
print(*iv)


n = int(input())
a = [int(x) - 1 for x in input().split()]
count = [0 for i in range(len(a))]
ans = [-1 for i in range(len(a))]
for i in range(len(a)):
	if a[i] < len(count):
		count[a[i]] += 1
for i in range(len(a)):
	if a[i] < len(count):
		if count[a[i]] >= 1:
			ans[i] = a[i]
			count[a[i]] = -1
jIt = 0
for i in range(len(ans)):
	if ans[i] == -1:
		while count[jIt] < 0:
			jIt += 1
		ans[i] = jIt
		jIt += 1
print(' '.join((str(x + 1) for x in ans)))


import sys, math
n = int(input())
a = [int(x) for x in input().split()]
s = set(a)
exist = set(s)
next = 1
for i in range(n):
	if a[i] <= n and a[i] in s:
		s.remove(a[i])
	else:
		while next in exist:
			next += 1
		a[i] = next
		next += 1
print(' '.join((str(x) for x in a)))


n = int(input())
b = set(range(1, n + 1))
c = []
for x in map(int, input().split()):
	if x in b:
		b.remove(x)
		c.append(x)
	else:
		c.append(None)
s = ''
for x in c:
	if x is None:
		s += str(b.pop()) + ' '
	else:
		s += str(x) + ' '
print(s)


def main():
	read = lambda : tuple(map(int, input().split()))
	n = read()[0]
	l = read()
	ans = [0] * (n + 1)
	was = [0] * (n + 1)
	c = 0
	for (i, v) in enumerate(l):
		if v >= 1 and v <= n and (not was[v]):
			was[v] = 1
			ans[i + 1] = v
	j = 1
	for v in range(1, n + 1):
		if not was[v]:
			while ans[j] != 0:
				j += 1
			ans[j] = v
	print(*ans[1:])
main()


n = int(input())
a = list(map(int, input().split(' ')))
numbers = set((i for i in range(1, n + 1)))
used = numbers & set(a)
left = list(numbers - used)
for i in range(n):
	if a[i] not in used:
		a[i] = left[0]
		left.remove(left[0])
	else:
		used.remove(a[i])
print(' '.join(map(str, a)))


n = int(input())
nums = [False] * n
seen = [False] * n
i = 0
A = list(map(int, input().split()))
for num in A:
	if 1 <= num <= n:
		nums[num - 1] = True
for num in A:
	if 1 <= num <= n:
		if not seen[num - 1]:
			seen[num - 1] = True
			print(num, end=' ')
		else:
			while nums[i]:
				i += 1
			nums[i] = True
			i += 1
			print(i, end=' ')
	else:
		while nums[i]:
			i += 1
		nums[i] = True
		i += 1
		print(i, end=' ')


n = int(input())
A = list(map(int, input().split()))
E = []
E = set(E)
QQQ = []
for i in range(n):
	QQQ.append(i + 1)
	if A[i] in E:
		A[i] = '0'
	else:
		E.add(A[i])
QQQ = set(QQQ)
E = QQQ - E
E = list(E)
G = 0
P = []
for i in range(n):
	if A[i] != '0' and 1 <= A[i] <= n:
		P.append(A[i])
	else:
		P.append(E[G])
		G += 1
print(*P)


q = int(input())
l = list(map(int, input().split()))
count = {}
a = set()
b = set(range(1, q + 1))
ind = []
i = 0
sat = 0
for e in l:
	if e <= q:
		if e not in count:
			count[e] = 1
			a.add(e)
		else:
			count[e] += 1
		if count[e] > 1:
			ind.append(i)
	else:
		ind.append(i)
		sat = 1
	i += 1
c = b.difference(a)
j = 0
if len(ind) != 0:
	for e in c:
		l[ind[j]] = e
		j += 1
	print(*l)
elif sat == 0 and len(ind) == 0:
	print(*l)


n = int(input())
l = list(map(int, input().split()))
dp = [0 for i in range(n + 1)]
pos = []
for i in range(n):
	flag = 0
	if l[i] <= n:
		if dp[l[i]] == 0:
			dp[l[i]] = 1
			flag = 1
	if not flag:
		pos.append(i)
j = 0
for i in range(1, n + 1):
	if dp[i] == 0:
		l[pos[j]] = i
		j += 1
for i in range(n):
	print(l[i], end=' ')
print()