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.

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Greedy algorithms


Solutions:
from collections import Counter
n = int(input())
c = list(map(int, input().split()))
count = Counter(c)
unused = list(set(range(1, n + 1)) - set(count.keys()))
for i in range(n):
	if count[c[i]] > 1 or c[i] > n or c[i] <= 0:
		count[c[i]] -= 1
		c[i] = unused.pop()
print(' '.join(map(str, c)))


n = int(input())
arr = list(map(int, input().split()))
dp = [0] * (n + 1)
for i in arr:
	if i <= n:
		dp[i] += 1
ar = []
for i in range(1, n + 1):
	if dp[i] == 0:
		ar.append(i)
cnt = 0
for i in range(n):
	if arr[i] > n:
		arr[i] = ar[cnt]
		cnt += 1
	elif dp[arr[i]] >= 2:
		dp[arr[i]] -= 1
		arr[i] = ar[cnt]
		cnt += 1
print(*arr)


N = int(input())
A = list((int(i) for i in input().split()))
B = list(A)
B.sort()
missing = set()
double = dict()
expected = 1
for i in range(N):
	if B[i] in double:
		double[B[i]] += 1
	else:
		double[B[i]] = 1
	missing.add(i + 1)
for i in range(N):
	if i + 1 in double and double[i + 1] == 1:
		del double[i + 1]
	if i + 1 in double:
		double[i + 1] -= 1
	if B[i] in missing:
		missing.remove(B[i])
for i in range(N):
	if A[i] in double:
		new = missing.pop()
		old = A[i]
		A[i] = new
		double[old] -= 1
		if double[old] <= 0:
			del double[old]
for i in range(N):
	if i > 0:
		print(' ', end='')
	print(A[i], end='')
print()


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)


n = int(input())
A = list(map(int, input().split()))
used = [False] * (n + 1)
for a in A:
	if a <= n:
		used[a] = True
unused = [i for (i, u) in enumerate(used[1:], 1) if not u]
result = []
for a in A:
	if a > n or used[a] == 2:
		result.append(unused.pop())
	else:
		used[a] += 1
		result.append(a)
print(*result)


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())
ans = [0] * 100003
lis = list(map(int, input().split()))
for i in range(n):
	ans[lis[i]] += 1
j = 1
for i in range(n):
	while j < n and ans[j]:
		j += 1
	if ans[lis[i]] > 1 or lis[i] > n:
		ans[j] += 1
		ans[lis[i]] -= 1
		lis[i] = j
print(*lis)


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)))


N = int(input())
things = list(map(int, input().split()))
ans = []
dif = set(things)
double = set()
to_zen = []
pnt = 0
for i in things:
	if i > N:
		dif.discard(i)
		to_zen += [pnt]
	elif i in double:
		to_zen += [pnt]
	double.add(i)
	pnt += 1
for i in range(1, N + 1):
	if i not in dif:
		things[to_zen.pop()] = i
		dif.add(i)
print(' '.join(list(map(str, things))))


n = int(input())
a = list(map(int, input().split()))
mp = {}
for ai in a:
	if ai in mp:
		mp[ai] += 1
	else:
		mp[ai] = 1
num = 1
for i in range(n):
	if a[i] > n or (a[i] in mp and mp[a[i]] > 1):
		if a[i] in mp:
			mp[a[i]] -= 1
		while num in mp:
			num += 1
		a[i] = num
		mp[a[i]] = 1
for ai in a:
	print(ai, end=' ')


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 sys import stdin, stdout
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
used = [False] * n
fixed = [False] * n
for i in range(n):
	if a[i] < n + 1:
		if not used[a[i] - 1]:
			used[a[i] - 1] = True
			fixed[i] = True
avail = []
for i in range(n):
	if not used[i]:
		avail.append(i + 1)
for i in range(n):
	if not fixed[i]:
		a[i] = avail.pop()
stdout.write(' '.join(map(str, a)))


from collections import Counter
n = int(input())
A = list(map(int, input().split()))

def change():
	set_list = set(A)
	for i in range(1, n + 1):
		if i not in set_list:
			yield i
C = Counter(A)
ch = change()
for i in range(n):
	if C[A[i]] > 1:
		C[A[i]] -= 1
		A[i] = next(ch)
	elif A[i] > n:
		A[i] = next(ch)
for i in A:
	print(i, end=' ')


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())
a = list(map(int, input().split()))
c = [0] * 100000
for i in range(n):
	c[a[i] - 1] += 1
s = []
for i in range(n):
	if c[i] == 0:
		s.append(i + 1)
if not s:
	print(*a)
	return
ans = a[:]
x = 0
for i in range(n):
	if c[a[i] - 1] > 1 or a[i] > n:
		c[a[i] - 1] -= 1
		ans[i] = s[x]
		x += 1
print(*ans)


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)]))


n = int(input())
db = [int(t) for t in input().split()]
seen = set()
needed = list({i for i in range(1, n + 1)} - set(db))
for i in range(len(db)):
	if db[i] > n or db[i] in seen:
		db[i] = needed.pop()
	else:
		seen.add(db[i])
for k in db[:-1]:
	print(k, end=' ')
print(db[-1])


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=' ')


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from operator import add
inf = float('inf')
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
n = ii()
arr = rr()
x = Counter(arr)
need = set(list(range(1, n + 1)))
for i in x.keys():
	try:
		need.remove(i)
	except:
		pass
for (i, j) in enumerate(arr):
	if x[j] > 1 or j > n:
		x[j] -= 1
		c = next(iter(need))
		arr[i] = c
		need.remove(c)
print(*arr)


__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())
seen = [0 for _ in range(100001)]
arr = list(map(int, input().split()))
notseen = []
for i in arr:
	seen[i] += 1
for i in range(1, n + 1):
	if seen[i] == 0:
		notseen.append(i)
for i in range(n):
	if seen[arr[i]] > 1 or arr[i] > n:
		nxt = notseen.pop()
		print(nxt, end=' ')
		seen[nxt] += 1
		seen[arr[i]] -= 1
	else:
		print(arr[i], end=' ')


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())
l = list(map(int, input().split()))
d = [0] * 100005
for i in range(n):
	d[l[i]] += 1
k = 1
for i in range(n):
	while k < n and d[k]:
		k += 1
	if d[l[i]] > 1 or l[i] > n:
		d[k] += 1
		d[l[i]] -= 1
		l[i] = k
print(*l)


import sys
n = int(input())
x = str(input()).split()
a = {a: 1 for a in range(1, n + 1)}
c = []
for i in range(n):
	if int(x[i]) > n:
		c.append(i)
		continue
	if a.get(int(x[i])) == 1:
		a.pop(int(x[i]))
		continue
	else:
		c.append(i)
for i in range(len(c)):
	x[c[i]] = a.popitem()[0]
for i in range(n - 1):
	print(x[i], end=' ')
print(x[n - 1])


n = int(input())
a = list(map(int, input().split()))
d = [0] * 100001
for ai in a:
	d[ai] += 1
b = [x for x in range(1, n + 1) if d[x] == 0]
j = 0
for (i, ai) in enumerate(a):
	if d[ai] > 1 or ai > n:
		a[i] = b[j]
		j += 1
		d[ai] -= 1
print(' '.join(map(str, a)))


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)


n = int(input())
p = [-1] * n
a = list(map(int, input().split()))
for i in range(n):
	a[i] -= 1
	if a[i] < n:
		p[a[i]] = i
j = 0
for i in range(n):
	if a[i] >= n or p[a[i]] != i:
		while p[j] != -1:
			j += 1
		p[j] = i
		a[i] = j
for i in a:
	print(i + 1, end=' ')


from collections import *
n = int(input())
x = list(map(int, input().split()))
d = defaultdict(int)
for i in x:
	d[i] += 1
m = 1
for i in range(n):
	if d[x[i]] > 1 or x[i] > n:
		d[x[i]] -= 1
		while d[m] > 0:
			m += 1
		x[i] = m
		m += 1
	print(x[i], end=' ')


n = int(input())
x = list(map(int, input().split()))
h = [0] * (n + 1)
for i in x:
	if i <= n:
		h[i] += 1
c = 0
y = []
for i in range(1, n + 1):
	if h[i] == 0:
		y.append(i)
j = 0
for i in range(n):
	if x[i] < 1 or x[i] > n or h[x[i]] > 1:
		if x[i] >= 1 and x[i] <= n:
			h[x[i]] -= 1
		x[i] = y[j]
		j += 1
		if j == len(y):
			break
for i in x:
	print(i, end=' ')


__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)


n = int(input())
a = [int(x) for x in input().split()]
cnt = [0] * 100013
for i in a:
	cnt[i] += 1
need = []
for i in range(1, n + 1):
	if cnt[i] == 0:
		need.append(i)
on = 0
for i in a:
	if i > n:
		print(need[on])
		on += 1
	elif cnt[i] > 1:
		print(need[on])
		on += 1
		cnt[i] -= 1
	else:
		print(i)


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


n = int(input())
l = list(map(int, input().split()))
l2 = [0 for i in range(1, n + 1)]
y = []
no = []
for i in range(n):
	if l[i] <= n:
		if l2[l[i] - 1] == 0:
			l2[l[i] - 1] = 1
			y.append(l[i])
for i in range(n):
	if l2[i] == 0:
		no.append(i + 1)
ans = []
l2 = [0 for i in range(1, n + 1)]
for i in range(n):
	if l[i] <= n:
		if l2[l[i] - 1] == 0:
			l2[l[i] - 1] = 1
			ans.append(l[i])
		else:
			ans.append(no.pop())
	else:
		ans.append(no.pop())
print(*ans)


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)


n = int(input())
contains = set()
res = []
for item in input().split(' '):
	num = int(item)
	val = None
	if num not in contains and num <= n:
		contains.add(num)
		val = num
	res.append(val)
missed_nums = list(set(range(1, n + 1)) - contains)
for i in res:
	if i is None:
		print(missed_nums.pop())
	else:
		print(i)


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) + ' ')


maxn = 100000 + 10
n = int(input())
cnt = [0] * maxn
a = [int(x) for x in input().split()]
for i in a:
	cnt[i] += 1
need = []
for i in range(1, n + 1):
	if cnt[i] == 0:
		need.append(i)
cur = 0
for i in a:
	if i > n:
		print(need[cur], end=' ')
		cur += 1
	elif cnt[i] > 1:
		print(need[cur], end=' ')
		cur += 1
		cnt[i] -= 1
	else:
		print(i, end=' ')


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()
n = ii()
p = [0] * n
v = [1] * (n + 1)
a = li()
for i in range(n):
	if a[i] <= n and v[a[i]]:
		p[i] = a[i]
		v[a[i]] = 0
i = 1
j = 0
while j < n:
	if not p[j]:
		if v[i]:
			p[j] = i
			i += 1
			j += 1
		else:
			i += 1
	else:
		j += 1
print(*p)


n = int(input())
a = list(map(int, input().split()))
x = [0] * 100001
z = [0] * 100001
y = list()
for i in range(0, n):
	x[a[i]] += 1
for i in range(1, n + 1):
	if x[i] == 0:
		y.append(i)
j = 0
for i in range(0, n):
	if z[a[i]] == 0 and a[i] <= n:
		print(a[i], end=' ')
		z[a[i]] = 1
	else:
		print(y[j], end=' ')
		j += 1


n = int(input())
inp = list(map(int, input().split(' ')))
toreplace = set()
values = set(range(1, n + 1))
for i in range(n):
	num = inp[i]
	if num in values:
		values.remove(num)
	else:
		toreplace.add(i)
for index in toreplace:
	inp[index] = values.pop()
print(*inp)


n = int(input())
pin = input().split(' ')
arr = [int(i) - 1 for i in pin]
free = [True] * n
change = []
for i in range(n):
	if arr[i] < n:
		if free[arr[i]]:
			free[arr[i]] = False
		else:
			change.append(i)
	else:
		change.append(i)
for i in range(n):
	if free[i]:
		arr[change.pop()] = i
for i in arr:
	print(i + 1, end=' ')


n = int(input())
val = [0 for i in range(n)]
a = list(map(int, input().split()))
for i in a:
	if i <= n:
		val[i - 1] += 1
notdone = []
for i in range(n):
	if val[i] == 0:
		notdone.append(i + 1)
curr = 0
for i in a:
	if i > n or val[i - 1] > 1:
		if i <= n:
			val[i - 1] -= 1
		print(notdone[curr], end=' ')
		curr += 1
	else:
		print(i, end=' ')


import queue
n = int(input())
mas = list(map(int, input().split(' ')))
s = set([i for i in range(1, n + 1)])
di = queue.Queue()
bo = 0
for i in range(n):
	if mas[i] in s:
		s.remove(mas[i])
	else:
		di.put(i)
for i in s:
	mas[di.get()] = i
print(' '.join(list(map(str, mas))))


from re import *
from sys import stderr

def readint():
	return int(input())

def readfloat():
	return float(input())

def readarray(N, foo=input):
	return [foo() for i in range(N)]

def readlinearray(foo=int):
	return map(foo, input().split())

def NOD(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def gen_primes(max):
	primes = [1] * (max + 1)
	for i in range(2, max + 1):
		if primes[i]:
			for j in range(i + i, max + 1, i):
				primes[j] = 0
	primes[0] = 0
	return [x for x in range(max + 1) if primes[x]]

def is_prime(N):
	i = 3
	if not N % 2:
		return 0
	while i * i < N:
		if not N % i:
			return 0
		i += 3
	return 1
n = readint()
a = list(readlinearray())
from collections import Counter
min_ok = 1
c = Counter(a)
for (i, x) in enumerate(a):
	if x > n or c[x] > 1:
		while c[min_ok] > 0:
			min_ok += 1
		a[i] = min_ok
		c[x] -= 1
		c[min_ok] += 1
print(' '.join(map(str, a)))


import unittest
import sys
import collections

class Inv:
	N = 100002

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		self.imax = int(uinput())
		self.nums = list(map(int, uinput().split()))
		self.cnt = [0] * self.N
		for i in range(self.imax):
			self.cnt[self.nums[i]] += 1
		self.empty = collections.deque()
		for i in range(1, self.N):
			if self.cnt[i] == 0:
				self.empty.append(i)

	def calculate(self):
		result = []
		for i in range(self.imax):
			num = self.nums[i]
			if self.cnt[num] > 1 or num > self.imax:
				e = self.empty.popleft()
				self.cnt[num] -= 1
				result.append(e)
			else:
				result.append(num)
		return str(' '.join(map(str, result)))

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '3\n1 3 2'
		d = Inv(test)
		self.assertEqual(d.imax, 3)
		self.assertEqual(d.nums, [1, 3, 2])
		self.assertEqual(Inv(test).calculate(), '1 3 2')
		test = '4\n2 2 3 3'
		self.assertEqual(Inv(test).calculate(), '1 2 4 3')
		test = '1\n2'
		self.assertEqual(Inv(test).calculate(), '1')
		self.time_limit_test(100000)

	def time_limit_test(self, imax):
		import random
		import timeit
		test = str(imax) + '\n'
		nums = [random.randint(1, imax) for i in range(imax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Inv(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Inv().calculate())


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())
arr = list(map(int, input().split()))
(cnt, y, unvis) = ([0] * (n + 1), [], [])
for i in range(n):
	if arr[i] <= n and cnt[arr[i] - 1] == 0:
		cnt[arr[i] - 1] = 1
		y.append(arr[i])
for i in range(n):
	if cnt[i] == 0:
		unvis.append(i + 1)
res = []
cnt = [0] * (n + 1)
for i in range(n):
	if arr[i] <= n and cnt[arr[i] - 1] == 0:
		cnt[arr[i] - 1] = 1
		res.append(arr[i])
	else:
		res.append(unvis.pop())
print(*res)


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 = [int(i) for i in input().split(' ')]
m = {}
for i in range(1, 100001):
	m[i] = []
zeroIndexes = []
for i in range(n):
	m[a[i]].append(i)
for i in range(1, n + 1):
	if len(m[i]) == 0:
		zeroIndexes.append(i)
for i in range(1, 100001):
	if len(m[i]) == 0:
		continue
	mx = 1 if i <= n else 0
	while len(m[i]) > mx:
		a[m[i][-1]] = zeroIndexes[-1]
		m[i].pop()
		zeroIndexes.pop()
print(' '.join([str(s) for s in a]))


import sys
n = int(input())
arr = list(map(int, input().split()))
store = [0] * n
for i in range(n):
	if arr[i] > n:
		continue
	elif store[arr[i] - 1] == 0:
		store[arr[i] - 1] = 1
	else:
		store[arr[i] - 1] += 1
zero = []
for i in range(n):
	if store[i] == 0:
		zero.append(i + 1)
pos = 0
p = 1
for i in range(n):
	if arr[i] > n:
		if pos < len(zero):
			arr[i] = zero[pos]
			pos += 1
		else:
			arr[i] = p
			if p < n:
				p += 1
			else:
				p = 1
	elif store[arr[i] - 1] > 1:
		store[arr[i] - 1] -= 1
		arr[i] = zero[pos]
		pos += 1
print(*arr, sep=' ')


n = int(input())
a = input().split()
d = {}
for i in range(n):
	d[i + 1] = 0
for i in range(n):
	a[i] = int(a[i])
	if not a[i] in d:
		d[a[i]] = 1
	else:
		d[a[i]] += 1
nls_pos = []
for i in range(n):
	if d[i + 1] == 0:
		nls_pos.append(i + 1)
for i in range(n):
	if d[a[i]] > 1 or a[i] > n:
		d[a[i]] -= 1
		a[i] = nls_pos[-1]
		nls_pos.pop()
for i in a:
	print(i, end=' ')


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=' ')


m = int(input())
(l, x) = ([], [])
d = {}
for i in map(int, input().split()):
	l.append(i)
	if i in d:
		d[i] += 1
	else:
		d[i] = 0
c = 0
for i in range(1, m + 1):
	if i not in d:
		x.append(i)
for i in l:
	if d[i] > 0 or i > m:
		print(x[c])
		c += 1
		d[i] -= 1
	else:
		print(i)


n = int(input())
freq = [0 for i in range(1, n + 1)]
a = list(map(int, input().split()))
for i in a:
	if i > n:
		continue
	freq[i - 1] += 1
j = 0
for i in a:
	if i > n:
		while freq[j] != 0:
			j += 1
		freq[j] = 1
		print(j + 1, end=' ')
	elif freq[i - 1] > 1:
		while freq[j] != 0:
			j += 1
		freq[j] = 1
		freq[i - 1] -= 1
		print(j + 1, end=' ')
	elif freq[i - 1] == 1:
		print(i, 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())
l = []
for i in range(n):
	l.append(0)
l1 = [int(i) for i in input().split()]
for i in l1:
	if i <= n:
		l[i - 1] += 1
x = -1
try:
	x = l.index(0)
except:
	pass
if x == -1:
	for i in l1:
		print(i, end=' ')
else:
	for i in range(n):
		if l1[i] > n:
			l1[i] = x + 1
			l[x] = 1
			f = 0
			while True:
				try:
					if l[x] == 0:
						break
					else:
						x += 1
				except:
					f = 1
					break
			if f == 1:
				break
		elif l[l1[i] - 1] != 1:
			l[l1[i] - 1] -= 1
			l1[i] = x + 1
			l[x] = 1
			f = 0
			while True:
				try:
					if l[x] == 0:
						break
					else:
						x += 1
				except:
					f = 1
					break
			if f == 1:
				break
	for i in l1:
		print(i, end=' ')


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())
t = list(map(int, input().split()))
f = {}
for j in t:
	if j not in f:
		f[j] = 1
	else:
		f[j] += 1
u = []
for i in range(1, n + 1):
	if i not in f:
		u.append(i)
if len(u) == 0:
	print(*t)
else:
	for j in range(n):
		if t[j] in f:
			if f[t[j]] > 1:
				f[t[j]] -= 1
				t[j] = u.pop()
	for j in range(n):
		if t[j] > n:
			t[j] = u.pop()
	print(*t)


n = int(input().strip())
l = list(map(int, input().split()))
d = dict.fromkeys(range(1, n + 1), 0)
for e in l:
	if e in d:
		d[e] += 1
missing = []
for k in d:
	if d[k] == 0:
		missing.append(k)
for e in l:
	if e not in d:
		print(missing.pop(), end=' ')
	elif d[e] == 1:
		print(e, end=' ')
	else:
		print(missing.pop(), end=' ')
		d[e] -= 1
print()


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


from collections import *
n = int(input())
a = list(map(int, input().split()))
lst = [0] * n
cnt = 0
for i in range(n):
	if a[i] <= n:
		lst[a[i] - 1] = 1
miss = []
for i in range(n):
	if lst[i] == 0:
		miss.append(i + 1)
lst = list(miss)
d = defaultdict(int)
for i in range(n):
	if a[i] > n:
		print(lst[-1], end=' ')
		lst.pop()
	elif d[a[i]] == 0:
		d[a[i]] += 1
		print(a[i], end=' ')
	else:
		print(lst[-1], end=' ')
		lst.pop()


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())
l = list(map(int, input().split()))
d = {}
for i in range(n):
	if l[i] in d:
		d[l[i]] += 1
	else:
		d[l[i]] = 1
notpre_ = []
for i in range(1, n + 1):
	if i in d:
		continue
	else:
		notpre_.append(i)
k = 0
for i in range(len(notpre_)):
	for j in range(k, len(l)):
		if d[l[j]] > 1 or l[j] > n:
			d[l[j]] = d[l[j]] - 1
			l[j] = notpre_[i]
			d[l[j]] = 1
			break
	k = j
print(*l)


n = int(input())
l = [int(i) for i in input().split()]
seen = [0] * (10 ** 5 + 9)
notthere = []
for i in l:
	seen[i] = 1
for i in range(1, n + 1):
	if seen[i] == 0:
		notthere.append(i)
seen = [0] * (10 ** 5 + 9)
for i in range(n):
	if seen[l[i]] == 0 and 1 <= l[i] <= n:
		seen[l[i]] = 1
	else:
		if not notthere:
			continue
		l[i] = notthere.pop()
print(*l)


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)


n = int(input())
nums = [int(x) - 1 for x in input().split()]
tracker = [0 for i in range(n)]
next_avail_num = set([i for i in range(n)])
for num in nums:
	if num < n:
		tracker[num] += 1
	next_avail_num.discard(num)
output = []
num_iter = iter(next_avail_num)
for num in nums:
	if num >= n:
		output.append(next(num_iter))
	elif tracker[num] > 1:
		tracker[num] -= 1
		output.append(next(num_iter))
	else:
		output.append(num)
print(' '.join([str(x + 1) for x in output]))


n = int(input())
a = map(int, input().split())
memo = [False] * n
res = [-1] * n
for (i, v) in enumerate(a):
	t = v - 1
	if t < n and memo[t] == False:
		memo[t] = True
		res[i] = v
notin = list()
for i in range(0, n):
	if memo[i] == False:
		notin.append(i + 1)
for (i, v) in enumerate(res):
	if v == -1:
		res[i] = notin.pop()
print(*res)


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)


n = int(input())
a = list(map(int, input().split()))
(d, m) = ({}, [])
for v in a:
	if v in d:
		d[v] += 1
	else:
		d[v] = 1
for i in range(1, n + 1):
	if i not in d:
		m.append(i)
for (i, v) in enumerate(a):
	if d[v] > 1 or (d[v] > 0 and v > n):
		a[i] = m.pop()
		d[v] -= 1
print(*a)


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()