Given an array $a$ of length $n$, find another array, $b$, of length $n$ such that:

  for each $i$ $(1 \le i \le n)$ $MEX(\{b_1$, $b_2$, $\ldots$, $b_i\})=a_i$. 

The $MEX$ of a set of integers is the smallest non-negative integer that doesn't belong to this set.

If such array doesn't exist, determine this.


-----Input-----

The first line contains an integer $n$ ($1 \le n \le 10^5$) — the length of the array $a$.

The second line contains $n$ integers $a_1$, $a_2$, $\ldots$, $a_n$ ($0 \le a_i \le i$) — the elements of the array $a$. It's guaranteed that $a_i \le a_{i+1}$ for $1\le i < n$. 


-----Output-----

If there's no such array, print a single line containing $-1$.

Otherwise, print a single line containing $n$ integers $b_1$, $b_2$, $\ldots$, $b_n$ ($0 \le b_i \le 10^6$)

If there are multiple answers, print any.


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

Output
0 1 2 
Input
4
0 0 0 2

Output
1 3 4 0 
Input
3
1 1 3

Output
0 2 1 


-----Note-----

In the second test case, other answers like $[1,1,1,0]$, for example, are valid.

Difficulty: MEDIUM_HARD

Solutions:
n = int(input())
l = list(map(int, input().split()))
ans = []
d = [False] * 202000
for i in l:
	d[i] = True
for i in range(202000):
	if not d[i]:
		ans.append(i)
lp = 1
print(ans[0], end=' ')
for i in range(1, n):
	if l[i] != l[i - 1]:
		print(l[i - 1], end=' ')
	else:
		print(ans[lp], end=' ')
		lp += 1
print()


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

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

def main():
	n = itg()
	arr = tuple(mpint())
	have_ans = all([arr[i] <= arr[i + 1] and arr[i] <= i + 1 for i in range(n - 1)])
	if not have_ans:
		return [-1]
	aa = set(arr)
	bb = sorted(set(range(n + 7)) - aa, reverse=True)
	aa = sorted(aa, reverse=True)
	ans = [bb.pop()]
	for i in range(1, n):
		if arr[i - 1] != arr[i]:
			ans.append(aa.pop())
		else:
			ans.append(bb.pop())
	return ans
print(*main())


n = int(input())
l = set()
a = list(map(int, input().split()))
l = set(a)
ans = 0
ans_t = []
v = []
for _ in range(n):
	if not _:
		while ans in l:
			ans = ans + 1
		ans_t.append(ans)
		ans = ans + 1
	elif a[_] != a[_ - 1]:
		ans_t.append(a[_ - 1])
	else:
		while ans in l:
			ans = ans + 1
		ans_t.append(ans)
		ans = ans + 1
print(*ans_t, sep=' ')


n = int(input())
a = [int(x) for x in input().split()]
b = [-1] * n
set_a = set(a)
for i in range(n - 1, 0, -1):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
c = 0
for i in range(n):
	if b[i] == -1:
		while c in set_a:
			c += 1
		b[i] = c
		c += 1
if max(a) - max(b) > 1:
	print(-1)
else:
	print(*b)


from sys import stdin

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

def sinput():
	return input()

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

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

def fill_with(x):
	if x not in s:
		return True
	return False
n = iinput()
a = linput()
s = set(a)
b = [0] * n
x = 0
while not fill_with(x):
	x += 1
b[0] = x
x += 1
for i in range(1, n):
	if a[i] > a[i - 1]:
		b[i] = a[i - 1]
	else:
		while not fill_with(x):
			x += 1
		b[i] = x
		x += 1
print(*b)


from sys import stdin, stdout
n = int(stdin.readline())
a = list(map(int, stdin.readline().strip().split()))
c = set(a)
d = []
for i in range(n + 1):
	if i not in c:
		d.append(i)
b = []
j = 0
for i in range(n):
	if i != 0:
		if a[i - 1] < a[i]:
			b.append(a[i - 1])
		else:
			b.append(d[j])
			j = j + 1
	else:
		b.append(d[j])
		j = j + 1
print(*b)


def answer(n, A):
	q = [0] * (n + 2)
	for i in A:
		q[i] = 1
	l = [i for i in range(n + 2) if q[i] == 0]
	b = []
	for i in range(n - 1):
		if A[i] != A[i + 1]:
			b.append(l[0])
			l[0] = A[i]
		else:
			b.append(l[0])
			del l[0]
	b.append(l.pop(0))
	return b
n = int(input())
A = list(map(int, input().split()))
print(*answer(n, A))


def main():
	n = int(input())
	lst = list(map(int, input().split()))
	reserve = set()
	if lst[0] > 1:
		print(-1)
		return
	for i in range(0, n):
		if lst[i] > i + 1:
			print(-1)
			return
		reserve.add(lst[i])
	can_use = []
	cur = lst[0]
	for i in range(0, n + 1):
		if not i in reserve:
			can_use.append(i)
	can_use.reverse()
	used = []
	for i in range(0, n):
		if lst[i] == cur:
			if len(can_use) == 0:
				print(-1)
				return
			used.append(can_use.pop())
		else:
			if len(can_use) != 0 and can_use[-1] < cur:
				print(-1)
				return
			used.append(cur)
			cur = lst[i]
	line = ''
	for i in used:
		line += str(i) + ' '
	print(line)
t = 1
for i in range(t):
	main()


from heapq import heappush, heappop
n = int(input())
ar = list(map(int, input().split()))
valid = True
s = []
for i in range(n):
	if ar[i] > i + 1:
		valid = False
		break
	elif i > 0:
		for j in range(ar[i - 1] + 1, ar[i]):
			heappush(s, j)
	elif ar[0] == 1:
		heappush(s, 0)
if not valid:
	print(-1)
else:
	maxi = ar[-1] + 1
	s_len = len(s)
	for i in range(s_len, n):
		heappush(s, maxi)
		maxi += 1
	ans = []
	for i in range(n):
		k = heappop(s)
		ans.append(k)
		if i + 1 < n and ar[i] != ar[i + 1]:
			heappush(s, ar[i])
	print(*ans)


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
n = II()
a = LI()
(b, s) = ([-1] * n, set([a[-1]]))
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		s.add(b[i])
v = 0
for i in range(n):
	while v in s:
		v += 1
	if b[i] == -1:
		b[i] = v
		s.add(v)
print(*b)


def main():
	n = int(input())
	A = list(map(int, input().split()))
	B = [-1] * n
	N = 10 ** 6
	now = N
	TB = [True] * N
	if A[0] > 0:
		B[0] = 0
		TB[0] = False
	for i in range(1, n):
		a = A[i]
		ab = A[i - 1]
		if ab < a:
			if TB[ab]:
				B[i] = ab
				TB[ab] = False
	TB[A[-1]] = False
	indexb = 0
	for i in range(n):
		if B[i] != -1:
			continue
		for j in range(indexb, N):
			if TB[j]:
				TB[j] = False
				indexb = j + 1
				B[i] = j
				break
	indexa = 0
	TA = [True] * N
	for i in range(n):
		TA[B[i]] = False
		for j in range(indexa, N):
			if TA[j]:
				if A[i] != j:
					print(-1)
					return
				indexa = j
				break
	print(' '.join(map(str, B)))
main()


import sys
import math
from bisect import bisect_right as br
from itertools import combinations as cb

def int_arr():
	return list(map(int, sys.stdin.readline().strip().split()))

def str_arr():
	return list(map(str, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
n = int(input())
arr = int_arr()
s = set(arr)
arr.insert(0, arr[0])
ans = []
p = 0
x = 0
ind = 0
for i in range(1, n + 1):
	if arr[i] != arr[i - 1]:
		ans.append(arr[i - 1])
	else:
		while ind in s:
			ind += 1
		ans.append(ind)
		ind += 1
print(*ans)


n = int(input())
a = list(map(int, input().split()))

def ehab(n, a):
	set_a = set(a)
	b = []
	ans = []
	for i in range(n + 1):
		if i not in set_a:
			b.append(i)
	index_b = 0
	ans.append(b[0])
	index_b += 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			ans.append(a[i - 1])
		else:
			ans.append(b[index_b])
			index_b += 1
	return ans
print(' '.join(map(str, ehab(n, a))))


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
sol = [-1] * n
touse = list(range(n + 1))
if a[0] == 1:
	sol[0] = 0
	touse[0] = -1
for i in range(1, n):
	if a[i] > a[i - 1]:
		sol[i] = a[i - 1]
		touse[a[i - 1]] = -1
j = 0
touse[a[-1]] = -1
for i in range(n):
	if sol[i] == -1:
		while touse[j] == -1:
			j += 1
		sol[i] = touse[j]
		j += 1
print(*sol)


n = int(input())
A = list(map(int, input().split()))
z = True
for i in range(len(A)):
	if A[i] > i + 1:
		z = False
		break
if not z:
	print(-1)
else:
	C = []
	B = [-10]
	for i in range(1, len(A)):
		if A[i] != A[i - 1]:
			B.append(A[i - 1])
			C.append(A[i - 1])
		else:
			B.append(-10)
	C.append(A[-1])
	C.append(10 ** 18)
	q = 0
	X = 0
	for i in range(len(B)):
		if B[i] == -10:
			while X == C[q]:
				q += 1
				X += 1
			B[i] = X
			X += 1
	print(*B)


def solve_test_case(t):
	n = int(input())
	a = parse_array(int)
	a_set = set(a)
	b = []
	b_set = set()
	mex = 0
	max_b = -1

	def add_to_b(v):
		nonlocal b
		nonlocal b_set
		nonlocal mex
		nonlocal max_b
		b.append(v)
		b_set.add(v)
		max_b = max(max_b, v)
		if v == mex:
			while mex in b_set:
				mex += 1
	if a[0] == 1:
		add_to_b(0)
	elif a[0] > 1:
		print(-1)
		return
	else:
		i = 1
		while True:
			if i not in a_set:
				add_to_b(i)
				break
			i += 1
	possible = True
	for i in range(1, n):
		if a[i] > a[i - 1]:
			add_to_b(a[i - 1])
			if mex != a[i]:
				possible = False
				break
		else:
			v = max_b + 1
			while True:
				if v not in a_set:
					add_to_b(v)
					break
				v += 1
	if possible:
		print(' '.join(list(map(str, b))))
	else:
		print(-1)

def parse_array(f):
	return list(map(f, input().split()))
solve_test_case(0)


import sys, math
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math, itertools

def solve():
	N = getInt()
	A = getInts()
	B = []
	A_dict = {}
	for j in range(N):
		A_dict[A[j]] = j
	allowed_nums = [j for j in range(3 * N // 2, -1, -1) if j not in A_dict]
	for j in range(N):
		if A[j] > j + 1:
			return -1
		B.append(allowed_nums.pop())
		if A_dict[A[j]] == j:
			allowed_nums.append(A[j])
	print(*B)
solve()


def solve(arr):
	n = len(arr)
	for (a, b) in zip(arr, arr[1:]):
		if b - a < 0:
			return [-1]
	if any((a > i + 1 for (i, a) in enumerate(arr))):
		return [-1]
	seen = [False] * (n + 5)
	for a in arr:
		seen[a] = True
	res = [0] * n
	cur = 0
	for i in range(n):
		if i and arr[i] > arr[i - 1]:
			res[i] = arr[i - 1]
		else:
			while seen[cur]:
				cur += 1
			res[i] = cur
			cur += 1
	return res
input()
arr = list(map(int, input().split()))
print(*solve(arr))


import sys
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
vis = [0] * (n + 1)
b = [-1] * n
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		vis[arr[i - 1]] = 1
		b[i] = arr[i - 1]
k = 0
vis[arr[-1]] = 1
for i in range(n):
	if b[i] == -1:
		while vis[k] == 1:
			k += 1
		b[i] = k
		k += 1
print(*b)


n = int(input())
l = list(map(int, input().split()))
x = 1
prev = 0
s = set(l)
res = []
for i in l:
	if i != prev:
		res.append(prev)
		prev = i
	else:
		while x in s:
			x += 1
		res.append(x)
		x += 1
print(*res)


from collections import defaultdict
n = int(input())
a = [int(X) for X in input().split()]
a = a[::-1]
x = [-1 for i in range(n)]
for i in a:
	if i > n:
		print(-1)
		exit()
p = defaultdict(lambda : 0)
p[a[0]] = 1
j = 0
for i in range(n - 1):
	if a[i] != a[i + 1]:
		x[i] = a[i + 1]
		p[a[i + 1]] = 1
j = n
for i in range(n):
	while p[j] == 1:
		j -= 1
	if x[i] == -1:
		x[i] = j
		j -= 1
print(*x[::-1])


from fractions import Fraction
from collections import defaultdict
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
krish = 1000
raj = krish * 90
r = krish - 90
n = int(input())
l = list([int(x) for x in input().split()])
b = [-1] * n
s = set(l)
s1 = set()
for i in range(n + 1):
	if i not in s:
		s1.add(i)
for i in range(1, n):
	if l[i] != l[i - 1]:
		b[i] = l[i - 1]
bl = list(s1)
k = 0
for i in range(n):
	if b[i] == -1:
		b[i] = bl[k]
		k += 1
print(*b)
r -= 10


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7
T = 1
for _ in range(T):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	d = [-1] * n
	done = [False] * (n + 1)
	s = 0
	for i in range(n - 1):
		if a[i] == a[i + 1]:
			continue
		d[i + 1] = a[i]
		done[a[i]] = True
		s = i + 1
	d[0] = -1 if a[0] == 0 else 0
	if a[0] == 1:
		done[0] = True
	done[a[-1]] = True
	fin = []
	for i in range(n, -1, -1):
		if not done[i]:
			fin.append(i)
	for i in range(n):
		if d[i] == -1:
			d[i] = fin.pop()
	for h in d:
		print(h, end=' ')
	print('')


import sys
input = sys.stdin.buffer.readline
n = int(input())
a = [int(c) for c in input().split()]
b = [-1 for i in range(n)]
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
j = 0
s = set(a)
for i in range(n):
	if b[i] == -1:
		while j in s:
			j += 1
		b[i] = j
		j += 1
print(' '.join([str(c) for c in b]))


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')

def solve(n, a):
	d = {}
	for ai in a:
		if ai not in d:
			d[ai] = 0
		d[ai] += 1
	c = []
	i = 0
	while len(c) < n:
		if i not in d:
			c.append(i)
		i += 1
	b = [0] * n
	k = 0
	for i in range(n):
		if i == 0:
			b[i] = c[k]
			k += 1
		elif a[i] != a[i - 1]:
			b[i] = a[i - 1]
		else:
			b[i] = c[k]
			k += 1
	return b

def main():
	n = ri()
	a = ria()
	res = solve(n, a)
	if res == -1:
		wi(-1)
	else:
		wia(res)
main()


def solve(n, a):
	b = [None] * n
	u = set(a)
	for i in range(1, n):
		if a[i] > a[i - 1]:
			b[i] = a[i - 1]
		if a[i] > i + 1:
			return -1
	j = 0
	for i in range(n):
		if b[i] is not None:
			continue
		while j in u:
			j += 1
		b[i] = j
		u.add(j)
	return ' '.join(map(str, b))
n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))


from collections import Counter
from collections import defaultdict
from collections import deque
import math
import heapq
import sys
import io, os
input = sys.stdin.readline
from bisect import *
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().strip().split()))
rls = lambda : list(map(str, input().split()))
n = int(input().strip())
a = rl()
s = list(set(a))
s.sort()
d = defaultdict(lambda : -1)
ans = []
prev = 0
for i in s:
	d[i] = 1
f = 1
prev = -1
for i in range(0, n):
	if i != 0 and a[i] != a[i - 1]:
		ans.append(a[i - 1])
		continue
	while 1:
		prev = prev + 1
		if d[prev] == 1:
			continue
		else:
			break
	ans.append(prev)
	if a[i] - prev > 1:
		f = 0
		break
if f:
	mx = 0
	for i in range(0, n):
		mx = max(ans[i], mx)
		if a[i] - mx > 1:
			print(-1)
			exit()
	print(*ans)
else:
	print(-1)


from sys import stdin, stderr

def rl():
	return [int(w) for w in stdin.readline().split()]
(n,) = rl()
a = rl()
a_set = set(a)
free = 0
prev = 0
b = []
for cur in a:
	if cur != prev:
		b.append(prev)
		if free == prev:
			free += 1
		prev = cur
	else:
		while free in a_set:
			free += 1
		b.append(free)
		free += 1
print(*b)


n = int(input())
ls = list(map(int, input().split()))
cc = set()
res = [-1] * n
for i in range(n):
	if i > 0 and ls[i - 1] != ls[i]:
		res[i] = ls[i - 1]
		cc.add(ls[i - 1])
cc.add(ls[-1])
(p, cv) = (0, 0)
while p < n:
	while cv in cc:
		cv += 1
	while p < n and res[p] != -1:
		p += 1
	if p < n:
		res[p] = cv
		cv += 1
print(*res)


n = int(input())
a = list(map(int, input().split()))
k = 0
b = [0] * n
s = set(a)
t = [False for i in range(n)]
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		t[i] = True
m = 0
for i in range(n):
	if not t[i]:
		while True:
			if m not in s:
				b[i] = m
				break
			else:
				m += 1
		m += 1
for i in b:
	print(i, end=' ')


import sys

def read():
	return int(input())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

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

def solve():
	n = read()
	a = get_array()
	a = [0] + a
	b = [-1 for i in range(n + 1)]
	used = [False for i in range(n + 1)]
	for i in range(1, n + 1):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			used[b[i]] = True
	used[a[n]] = True
	m = 0
	for i in range(1, n + 1):
		if b[i] == -1:
			while used[m]:
				m += 1
			b[i] = m
			used[m] = True
	for i in range(1, n + 1):
		print('%d ' % b[i], end='')
	print()
solve()


n = int(input())
a = list(map(int, input().split()))
value = n
used = set()
b = [-1] * n
for i in range(n - 1, -1, -1):
	used.add(a[i])
	if i > 0 and a[i] > a[i - 1]:
		b[i] = a[i - 1]
	else:
		while value >= 0 and value in used:
			value -= 1
		if value >= 0:
			b[i] = value
			if value > 0:
				value -= 1
		else:
			b[i] = n
used = [0] * (n + 1)
mex = 0
for i in range(n):
	used[b[i]] = 1
	while used[mex]:
		mex += 1
	if a[i] != mex:
		print(-1)
		break
else:
	print(*b)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
(chk, mex, nxt, last) = (True, l[0], 0, -1)
final = []
for i in range(n):
	if l[i] > i + 1:
		chk = False
		break
	elif l[i] == last or last == -1:
		while nxt in s:
			nxt += 1
		last = l[i]
		final.append(nxt)
		nxt += 1
	else:
		s.remove(last)
		final.append(mex)
		mex = l[i]
		nxt = max(nxt, mex)
		last = l[i]
print(*(final if chk else -1))


import heapq
(n, a, b) = (int(input()), list(map(int, input().split())), [0] * 200000)
for i in range(n):
	b[a[i]] = 1
hp = [i for i in range(n + 1) if not b[i]]
heapq.heapify(hp)
for i in range(n - 1):
	print(heapq.heappop(hp), end=' ')
	if a[i] < a[i + 1]:
		heapq.heappush(hp, a[i])
print(heapq.heappop(hp))


n = int(input())
arr = [x for x in map(int, input().split(' '))]
b = []
last_seen = dict()
no_use = set()
for (i, v) in enumerate(arr):
	last_seen[v] = i
	no_use.add(v)
to_use = [x for x in range(n, -1, -1) if x not in no_use]
for (i, v) in enumerate(arr):
	b.append(to_use.pop())
	if last_seen[v] == i:
		to_use.append(v)
for v in b:
	print(v, end=' ')
print()


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

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

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

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

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	n = scan_int()
	a = read_list()
	s = set(a)
	now = 1
	p = 0
	for i in range(n):
		if a[i] != p:
			print(p, end=' ')
			p = a[i]
			if now == a[i]:
				now += 1
		else:
			while now in s:
				now += 1
			print(now, end=' ')
			now += 1
	print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
solve()


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = 1
for tc in range(t):
	n = int(stdin.readline())
	ar = list(map(int, stdin.readline().split()))
	resar = [-1 for _ in range(n)]
	res = 1
	if ar[0] > 1:
		res = -1
	else:
		if ar[0] == 1:
			resar[0] = 0
			lastval = 1
			curmex = 1
			curnext = 1
			nextskipi = 0
		else:
			i = 1
			while i < n and ar[i] <= ar[i - 1] + 1:
				i += 1
			resar[0] = ar[i - 1] + 1
			lastval = 0
			curmex = 0
			curnext = resar[0] + 1
			nextskipi = 0
		while nextskipi < n - 1 and ar[nextskipi] < curnext:
			nextskipi += 1
		while ar[nextskipi] == curnext:
			curnext += 1
			while nextskipi < n - 1 and ar[nextskipi] < curnext:
				nextskipi += 1
		sofar = set()
		sofar.add(resar[0])
		for i in range(1, n):
			if ar[i] == lastval:
				resar[i] = curnext
				sofar.add(curnext)
				curnext += 1
				while nextskipi < n - 1 and ar[nextskipi] < curnext:
					nextskipi += 1
				while ar[nextskipi] == curnext:
					curnext += 1
					while nextskipi < n - 1 and ar[nextskipi] < curnext:
						nextskipi += 1
			else:
				resar[i] = curmex
				sofar.add(curmex)
				while curmex in sofar:
					curmex += 1
			if curmex != ar[i]:
				res = -1
				break
			lastval = ar[i]
	if res == -1:
		stdout.write(str(res) + '\n')
	else:
		for val in resar:
			stdout.write(str(val) + ' ')
		stdout.write('\n')


import sys
input = sys.stdin.readline
from collections import *
from heapq import *
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
	if a[i] > i + 1:
		print(-1)
		exit()
s = set(a)
pq = []
for i in range(10 ** 6 + 1):
	if i not in s:
		heappush(pq, i)
ans = []
for i in range(n):
	if i >= 1 and a[i] > a[i - 1]:
		heappush(pq, a[i - 1])
	ans.append(heappop(pq))
print(*ans)


import heapq
n = int(input())
list1 = list(map(int, input().split()))
vist = [0] * 100002
for i in range(len(list1)):
	vist[list1[i]] += 1
f = 0
for i in range(len(list1)):
	if list1[i] > i + 1:
		f = 1
		break
if f == 1:
	print(-1)
else:
	p = []
	for i in range(len(vist)):
		if vist[i] == 0:
			p.append(i)
	heapq.heapify(p)
	ans = []
	for i in range(n):
		t = heapq.heappop(p)
		ans.append(t)
		vist[list1[i]] -= 1
		if vist[list1[i]] == 0:
			heapq.heappush(p, list1[i])
	print(*ans)


import math
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

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

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	result.append(n)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	n = int(input())
	l = list(map(int, input().split()))
	l1 = []
	for j in range(0, n):
		l1.append(-1)
	f = []
	for j in range(0, 1000000):
		f.append(-1)
	f[l[0]] = 1
	for j in range(1, n):
		if l[j - 1] != l[j]:
			l1[j] = l[j - 1]
			f[l[j - 1]] = 1
		f[l[j]] = 1
	k = 0
	for j in range(0, n):
		if l1[j] == -1:
			while k <= 1000000:
				if f[k] == -1:
					f[k] = 1
					l1[j] = k
					break
				k += 1
	print(*l1)
t = 1
for i in range(0, t):
	main()


import heapq
n = int(input())
a = list(map(int, input().split()))
fl = True
r = [0] * (n + 1)
s = set()
for i in range(n):
	s.add(a[i])
for i in s:
	r[i] = 1
t = []
for i in range(n + 1):
	if r[i] == 0:
		t.append(i)
heapq.heapify(t)
x = [-1] * n
for i in range(n - 1):
	if a[i] != a[i + 1]:
		x[i + 1] = a[i]
for i in range(n):
	if x[i] == -1:
		k = heapq.heappop(t)
		x[i] = k
print(*x)


import math

def findholes(arr):
	holes = [False] * 100005
	for a in arr:
		holes[a] = True
	ret = []
	for (i, h) in enumerate(holes):
		if h == False:
			ret.append(i)
	return ret

def findb(arr):
	holes = findholes(arr)
	holes = holes[::-1]
	b_array = []
	for (i, a) in enumerate(arr):
		if i > 0 and arr[i] > arr[i - 1]:
			holes.append(arr[i - 1])
		currhole = holes.pop(-1)
		b_array.append(currhole)
		if a < 0:
			return []
		if a != 0:
			if len(holes) > 0:
				if holes[-1] <= a - 1:
					return []
	return b_array
n = int(input())
a = [int(x) for x in input().split(' ')]
ans = findb(a)
if len(ans) == 0:
	print(-1)
else:
	print(' '.join([str(x) for x in ans]))


n = int(input())
l1 = list(map(int, input().split()))
s = set(l1)
s4 = list(s)
l = len(s4)
i = 0
m = 0
k = 0
l2 = [-1] * n
while i != n - 1:
	if l2[i] == -1:
		while k < l and m == s4[k]:
			m += 1
			k += 1
		l2[i] = m
		m += 1
	if l1[i + 1] > l1[i]:
		l2[i + 1] = l1[i]
	i += 1
if l2[i] == -1:
	while k < l and m == s4[k]:
		m += 1
		k += 1
	l2[i] = m
print(*l2)


from sys import stdin, setrecursionlimit, stdout
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 si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['Yes', 'No']
test_case = 1
while test_case:
	test_case -= 1
	n = ii()
	a = li()
	b = [-1] * n
	v = [0] * (2 * n + 3)
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
		v[a[i]] = 1
	v[a[0]] = 1
	j = 0
	for i in range(n):
		if b[i] == -1:
			while v[j]:
				j += 1
			b[i] = j
			j += 1
	print(*b)


n = int(input())
a = [int(x) for x in input().split()]
a.insert(0, 0)
ans = [-1] * n
used = [False] * (n + 1)
for i in range(1, n + 1):
	if a[i] != a[i - 1]:
		ans[i - 1] = a[i - 1]
		used[a[i - 1]] = 1
used[a[n]] = 1
cur = 0
for i in range(n):
	if ans[i] == -1:
		while used[cur]:
			cur += 1
		ans[i] = cur
		used[cur] = 1
print(*ans)


def read_ints():
	return list(map(int, input().split()))
(n,) = read_ints()
a = read_ints()
b = [-1] * n
used = set(a)
current = 0
j = 1
for i in range(n):
	if a[i] != current:
		b[i] = current
		current = a[i]
		if current > i + 1:
			print(-1)
			break
	else:
		while j in used:
			j += 1
		b[i] = j
		j += 1
else:
	print(*b)


def main():
	N = int(input())
	(*A,) = map(int, input().split())
	for (i, a) in enumerate(A):
		if i + 1 < a:
			print(-1)
			return
	else:
		Us = set(range(N + 1)) - set(A)
		U = sorted(Us)
		lU = len(U)
		ui = 0
		ans = []
		pre = A[0]
		for (i, a) in enumerate(A):
			if pre != a:
				ans.append(pre)
			else:
				if ui >= lU:
					print(-1)
					return
				ans.append(U[ui])
				ui += 1
			pre = a
		print(*ans)
main()


import math
n = int(input())
a = [int(i) for i in input().split()]
d = False
for i in range(n):
	if a[i] > i + 1 or (i < n - 1 and a[i + 1] < a[i]):
		print(-1)
		d = True
		break
if not d:
	out = [-1] * n
	for i in range(1, n):
		if a[i] != a[i - 1]:
			out[i] = str(a[i - 1])
		else:
			out[i] = -1
	next_ = n
	seen = {a[-1]}
	for i in range(n - 1, -1, -1):
		seen.add(a[i])
		if out[i] == -1:
			while next_ in seen:
				next_ -= 1
			out[i] = str(next_)
			next_ -= 1
	print(' '.join(out))


n = int(input())
a = [int(x) for x in input().split(' ')]
a_dict = {}
for item in a:
	if item in a_dict.keys():
		a_dict[item] += 1
	else:
		a_dict[item] = 1
m = 0
ans = []
skip_print = False
for i in range(n):
	if a[i] > i + 1:
		print(-1)
		skip_print = True
		break
	if i > 0 and a[i] != a[i - 1]:
		ans.append(a[i - 1])
	else:
		while m in a_dict.keys():
			m += 1
		ans.append(m)
		m += 1
if not skip_print:
	print(*ans)


n = int(input())
l = list(map(int, input().strip().split()))
b = [-1 for a in range(0, n)]
for i in range(0, n - 1):
	if l[i] != l[i + 1]:
		b[i + 1] = l[i]
t = set([j for j in range(0, 10 ** 6 + 1)]) - set(l)
t = list(t)
t.sort()
c = 0
for i in range(0, n):
	if b[i] == -1:
		b[i] = t[c]
		c += 1
print(' '.join((str(e) for e in b)))


import sys
pprint = lambda s: print(' '.join(map(str, s)))
input = lambda : sys.stdin.readline().strip()
ipnut = input
n = int(input())
a = [0] + list(map(int, input().split()))
ans = [-1] * n
used = set(a)
for i in range(n):
	if a[i] != a[i + 1]:
		ans[i] = a[i]
	if a[i + 1] > i + 1:
		print(-1)
		exit(0)
curr = 0
for i in range(n):
	if ans[i] == -1:
		curr += 1
		while curr in used:
			curr += 1
		ans[i] = curr
pprint(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
vals = list(map(int, input().split()))
noreps1 = set(vals)
noreps = list(noreps1)
noreps.sort()
maxy = vals[-1]
miny = vals[0]
posi = True
minsofar = 0
broke = False
for j in range(n):
	if j + 1 < vals[j]:
		broke = True
		break
if broke == True:
	print(-1)
else:
	outy = ['x'] * n
	cv = 0
	minsofar = 0
	if len(noreps1) >= 2:
		for s in range(n):
			if cv + 1 <= len(noreps) - 1 and vals[s] == noreps[cv + 1]:
				outy[s] = str(noreps[cv])
				cv += 1
	for s in range(n):
		if outy[s] == 'x':
			while minsofar in noreps1:
				minsofar += 1
			outy[s] = str(minsofar)
			minsofar += 1
	print(' '.join(outy))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
import heapq
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
inp = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 1000000007

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def solve():
	n = int(inp())
	a = lis()
	m = max(a)
	for i in range(0, n):
		if i >= a[i] - 1:
			continue
		else:
			print(-1)
			return
	b = [-1] * n
	nta = [False] * (m + 1)
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
	s = list(set(b))
	for i in s:
		nta[i] = True
	if a[0] == 0:
		curr = 1
	else:
		curr = 0
	toadd = []
	for i in range(0, m + 1):
		if nta[i] == False:
			toadd.append(i)
	for i in range(m + 1, 10 ** 6 + 1):
		toadd.append(i)
	j = 0
	for i in range(0, n):
		if b[i] == -1:
			b[i] = toadd[j]
			j += 1
	print(*b)
testcase(1)


import os
import sys
from io import BytesIO, IOBase
import threading

def main():
	for _ in range(1):
		n = int(input())
		arr = list(map(int, input().split()))
		ans = [-1] * n
		t = [0] * 10 ** 6
		t[arr[-1]] = 1
		for i in range(1, n):
			if arr[i] != arr[i - 1]:
				ans[i] = arr[i - 1]
				t[arr[i - 1]] = 1
		bi = 0
		for i in range(n):
			while t[bi] == 1:
				bi += 1
			if ans[i] == -1:
				ans[i] = bi
				bi += 1
		print(' '.join([str(i) for i in ans]))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1
answer_list = []

def read_s():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos].decode()

def read_i():
	return int(read_s())

def write_s(v):
	answer_list.append(v)

def write_i(v):
	write_s(str(v))

def print_ans():
	os.write(1, '\n'.join(answer_list).encode())
n = read_i()
a = [read_i() for i in range(n)]
need = [i != a[-1] for i in range(n + 1)]
ans = [-1 for i in range(n)]
for i in range(n):
	if i > 0 and a[i] != a[i - 1]:
		ans[i] = a[i - 1]
		need[ans[i]] = False
j = 0
for i in range(n):
	if ans[i] == -1:
		while not need[j]:
			j += 1
		ans[i] = j
		need[j] = False
write_s(' '.join([str(x) for x in ans]))
print_ans()


import sys

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

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

def SI():
	return sys.stdin.readline().strip()
n = II()
a = LI()
if a[0] not in [0, 1] or a != sorted(a):
	print(-1)
else:
	boo = True
	for i in range(n):
		if a[i] > i + 1:
			boo = False
			break
	if boo == False:
		print(-1)
	else:
		b = [-1] * n
		arr = list(range(n))
		if a[-1] < n:
			arr = list(range(n + 1))
			arr.pop(a[-1])
		d = {}
		for i in arr:
			d[i] = 0
		for i in range(n - 1, 0, -1):
			if a[i] > a[i - 1]:
				b[i] = a[i - 1]
				d[a[i - 1]] = 1
		temp = 0
		for i in range(n):
			if b[i] == -1:
				while d[arr[temp]] == 1:
					temp += 1
				b[i] = arr[temp]
				temp += 1
		print(*b)


t = 1
while t != 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	st = set()
	b = [-1 for _ in range(n)]
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			st.add(b[i])
	st.add(a[-1])
	m = 0
	for i in range(n):
		if b[i] == -1:
			while m in st:
				m += 1
			b[i] = m
			m += 1
	print(*b)


from sys import stdin
from collections import Counter
n = int(stdin.readline())
arr = list(map(int, stdin.readline().split()))
cou = Counter()
fl = 0
for val in arr:
	cou[val] += 1
see = set(arr)
if not fl:
	i = 1
	add = -1
	if arr[0] == 1:
		fin = [0]
		cou[1] -= 1
		if cou[1] == 0:
			add = 1
	else:
		fin = []
		for x in range(1, 10 ** 6):
			if x not in see:
				fin.append(x)
				break
		cou[0] -= 1
		if cou[0] == 0:
			add = 0
	se = set(fin)
	a = arr[0] + 1
	while len(fin) != n:
		if add != -1:
			fin.append(add)
			se.add(add)
			add = -1
			cou[arr[i]] -= 1
			if cou[arr[i]] == 0:
				add = arr[i]
			i += 1
			continue
		while cou.get(a) or a in se:
			a += 1
		fin.append(a)
		se.add(a)
		cou[arr[i]] -= 1
		if cou[arr[i]] == 0:
			add = arr[i]
		i += 1
	for i in fin:
		print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
flag = 1
v = [False for i in range(100001)]
for i in range(n):
	v[a[i]] = True
	if a[i] > i + 1:
		print(-1)
		flag = 0
		break
if flag == 1:
	b = [-1 for i in range(n)]
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			v[a[i - 1]] = True
	j = 0
	for i in range(n):
		if b[i] == -1:
			while b[i] == -1 and j < 100001:
				if v[j]:
					j += 1
				else:
					b[i] = j
					v[j] = True
	for i in b:
		print(i, end=' ')


import math, sys, bisect
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
N = int(input())
A = alele()
a = 0
b = 1
mark = {i: 1 for i in A}
for i in A:
	if i == a:
		while mark.get(b, 0) == 1:
			b += 1
		print(b, end=' ')
		b += 1
	else:
		print(a, end=' ')
		a = i


i_liczb = int(input())
a = [int(x) for x in input().split()]
a = [0] + a
if a[i_liczb] > i_liczb:
	print(-1)
	quit()
b = [-1 for _ in range(i_liczb + 1)]
wykorzystane = [False for _ in range(100005)]
for i in range(1, i_liczb + 1):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		wykorzystane[b[i]] = True
wykorzystane[a[i_liczb]] = True
x = 0
for i in range(1, i_liczb + 1):
	while wykorzystane[x]:
		x += 1
	if b[i] == -1:
		b[i] = x
		wykorzystane[x] = True
print(*b[1:])


from heapq import *
(n, *a) = map(int, open(0).read().split())
b = [-1] * n
unused = set(range(2 * n + 1))
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		unused.remove(a[i - 1])
unused.remove(a[-1])
hq = list(unused)
heapify(hq)
for i in range(n):
	if b[i] == -1:
		b[i] = heappop(hq)
print(*b)


n = int(input())
l = list(map(int, input().split()))
s = set(l)
x = 0
y = 1
for i in range(n):
	if l[i] != x:
		print(x, end=' ')
		x = l[i]
		if y == l[i]:
			y += 1
	else:
		while y in s:
			y += 1
		print(y, end=' ')
		y += 1


n = int(input())
a = list(map(int, input().split()))
b = [-1 for i in range(n)]
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
MEX = 0
j = 0
l = []
while j <= n - 1:
	if MEX < a[j]:
		l.append(MEX)
		MEX = MEX + 1
	elif MEX == a[j]:
		MEX = MEX + 1
		j = j + 1
	elif MEX > a[j]:
		j = j + 1
	else:
		l.append(MEX)
		MEX = MEX + 1
while len(l) < n:
	l.append(MEX)
	MEX = MEX + 1
j = 0
for i in range(n):
	if b[i] == -1:
		b[i] = l[j]
		j = j + 1
print(*b)


n = int(input())
l = input().split()
li = [int(i) for i in l]
lo = [0 for i in range(n)]
set = 0
done = [0 for i in range(n)]
hashi = dict()
for i in li:
	hashi[i] = 1
for i in range(n):
	if li[i] != 0 and i == 0:
		lo[i] = 0
		done[i] = 1
		hashi[0] = 1
		continue
	if li[i] != li[i - 1] and i != 0:
		lo[i] = li[i - 1]
		done[i] = 1
curr = 0
for i in range(n):
	if done[i] != 0:
		continue
	while curr in hashi:
		curr += 1
	lo[i] = curr
	curr += 1
for i in lo:
	print(i, end=' ')


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
f = 0
c = [0] * (n + 1)
for i in range(n):
	if i == 0:
		c[a[i]] = 1
	else:
		if a[i] > i + 1:
			f = 1
			break
		c[a[i]] = 1
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
if f:
	print(-1)
else:
	x = 0
	for i in range(n):
		if b[i] == -1:
			while c[x % (n + 1)]:
				x = (x + 1) % (n + 1)
			c[x % (n + 1)] = 1
			b[i] = x
	print(*b)


def help():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	ans_arr = [-1] * n
	dicti = {}
	if arr[0] == 1:
		ans_arr[0] = 0
		dicti[0] = 1
	for i in range(1, n):
		if arr[i] != arr[i - 1]:
			ans_arr[i] = arr[i - 1]
			dicti[arr[i - 1]] = 1
	dicti[arr[-1]] = 1
	m = 0
	for i in range(n):
		while dicti.get(m, -1) == 1:
			m += 1
		if ans_arr[i] == -1:
			ans_arr[i] = m
			dicti[m] = 1
	print(*ans_arr)
for _ in range(1):
	help()


n = int(input())
a = list(map(int, input().split()))
b = []
c = [0] * (n + 1)
d = [0] * (n + 1)
for i in range(n):
	c[a[i]] += 1
u = 0
v = c.index(0)
for i in range(n):
	if a[i] > u:
		b.append(u)
		d[u] = 1
		while u <= n and d[u] == 1:
			u += 1
		if u > v:
			v = u
			while v <= n and c[v] != 0:
				v += 1
	else:
		b.append(v)
		d[v] = 1
		c[v] = -1
		while v <= n and c[v] != 0:
			v += 1
print(*b)


n = int(input())
a = list(map(int, input().split()))
m = int(1000000.0)
b = [-1] * n
e = 0
v = [0] * m
for i in range(n):
	if a[i] != e:
		b[i] = e
		v[e] = 1
		e = a[i]
v[e] = 1
k = 0
for i in range(n):
	while v[k] == 1:
		k += 1
	if b[i] == -1:
		b[i] = k
		v[k] = 1
print(*b)


v = [0 for i in range(1000006)]
n = int(input())
a = [0]
a += list(map(int, input().split()))
flag = 1
for i in range(1, n + 1):
	if a[i] > i:
		flag = 0
		break
	v[a[i]] = 1
if flag == 0:
	print(-1)
else:
	b = [-1 for i in range(n + 1)]
	for i in range(2, n + 1):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			v[a[i - 1]] = 1
	nv = []
	for i in range(1000006):
		if v[i] == 0:
			nv.append(i)
	j = 0
	for i in range(1, n + 1):
		if b[i] == -1:
			b[i] = nv[j]
			j += 1
	for i in range(1, n + 1):
		print(b[i], end=' ')


import sys
input = sys.stdin.buffer.readline

def iinp() -> int:
	return int(input())

def linp() -> list:
	return [int(p) for p in input().split()]

def sinp():
	return input().decode('unicode-escape')[0:-2]
n = iinp()
a = linp()
s = set(a)
x = 0
y = 1
for i in a:
	if i == x:
		while y in s:
			y += 1
		print(y, end=' ')
		y += 1
	else:
		print(x, end=' ')
		x = i


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
if a[0] == 0 or a[0] == 1:
	maxi = -1
	if a[0] == 1:
		b[0] = 0
		maxi = 0
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
	tofill = []
	i = 0
	while i < n:
		if b[i] == -1:
			tofill.append(i)
		elif b[i] != -1 and len(tofill) != 0:
			maxi = max(maxi, a[i - 1])
			for j in range(len(tofill)):
				if maxi != a[i] - 1:
					b[tofill[0]] = maxi + 1
					tofill.pop(0)
					maxi += 1
				else:
					break
			if maxi != a[i] - 1:
				print(-1)
				break
		i += 1
	if len(tofill) == 0 and b.count(-1) != 0:
		pass
	else:
		maxi = a[-1]
		for i in range(len(tofill)):
			b[tofill[i]] = maxi + 1
			maxi += 1
		print(*b)
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
f = 1
for i in range(n):
	if a[i] > i + 1:
		f = 0
		break
if f == 0:
	print(-1)
else:
	ans = [-1] * (n + 1)
	ind = [-1] * (n + 1)
	for i in range(n):
		ind[a[i]] = i
	done = [0] * (n + 1)
	for i in range(len(ind)):
		if ind[i] != -1:
			ans[ind[i] + 1] = i
			done[i] = 1
	i = 0
	j = 0
	while i < n:
		if ans[i] == -1:
			while j < n + 1:
				if done[j] == 0:
					ans[i] = j
					done[j] = 1
					break
				else:
					j += 1
		i += 1
	print(*ans[0:n])


import sys
n = int(input())
mas = list(map(int, input().split()))
s = set(mas)
now = 1
p = 0
for i in range(n):
	if mas[i] != p:
		print(p, end=' ')
		p = mas[i]
		if now == mas[i]:
			now += 1
	else:
		while now in s:
			now += 1
		print(now, end=' ')
		now += 1
print()


n = int(input())
a = list(map(int, input().split()))

def add(i):
	r = []
	if c[i]:
		while c[i]:
			r.append(i)
			i += 1
	return (i, r)
aa = set(a)
f = {i: 0 for i in aa}
for i in a:
	f[i] += 1
c = [False for i in range(n + 20)]
for i in a:
	c[i] = True
d = [i for i in aa][::-1]
rest = set()
i = 0
b = []
while d:
	if len(rest) > 1:
		print(-1)
		exit()
	t = 0
	x = d.pop()
	if rest:
		b.append(rest.pop())
		t += 1
	rest.add(x)
	while t < f[x]:
		(i, r) = add(i)
		b.append(i)
		i += 1
		rest.union(r)
		t += 1
print(*b)


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
l = [0] * (10 ** 5 + 1)
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		l[b[i]] = 1
l[a[n - 1]] = 1
d = []
for i in range(10 ** 5 + 1):
	if l[i] == 0:
		d.append(i)
k = 0
for i in range(n):
	if b[i] == -1:
		b[i] = d[k]
		k += 1
print(*b)


N = int(input())
A = list(map(int, input().split()))
rs = set(A)
mx = -1
p = -1
ans = []
for a in A:
	if p >= 0 and p != a:
		ans.append(p)
		if p == mx + 1:
			mx += 1
	else:
		mx += 1
		while mx in rs:
			mx += 1
		ans.append(mx)
	if mx + 1 < a:
		print(-1)
		exit()
	p = a
print(*ans)


n = int(input())
a = list(map(int, input().split()))
i = 0
temp = -1
b = [-1] * n
while i < n - 1:
	if a[i] != a[i + 1]:
		temp = a[i]
		b[i + 1] = temp
	i += 1
x = b.count(-1)
lis = [-1] * (n + 1)
for i in range(n):
	lis[a[i]] = 0
y = lis.count(-1)
arr = []
p = n + 1
for i in range(p):
	if lis[i] == -1:
		arr.append(i)
j = 0
for i in range(n):
	if b[i] == -1:
		b[i] = arr[j]
		j += 1
print(' '.join((str(x) for x in b)))


import math
import sys
from itertools import permutations
input = sys.stdin.readline
n = int(input())
arr = list(map(int, input().split()))
if arr[-1] == '\n':
	arr.pop()
ans = [-1] * n
tot = [0]
for i in range(n - 1):
	if arr[i] != arr[i + 1]:
		ans[i + 1] = arr[i]
		tot.append(i + 1)
if n == 1:
	pass
elif arr[-1] != arr[-2]:
	tot.append(n - 1)
cur = 0
done = 0
for i in range(n):
	if ans[i] == -1:
		while cur < len(tot) and done == arr[tot[cur]]:
			done += 1
			cur += 1
		if cur > len(tot):
			break
		ans[i] = done
		done += 1
print(*ans)


import os, io
import sys
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
failflag = 0
visited = set()
visited.add(a[0])
for i in range(1, n):
	if a[i - 1] != a[i]:
		b[i] = a[i - 1]
	if a[i] > i + 1:
		failflag = 1
		break
	visited.add(a[i])
if failflag == 1:
	print(-1)
	sys.exit()
counter = 0
visited2 = set()
for i in range(n):
	while counter in visited:
		counter += 1
	if b[i] == -1:
		b[i] = counter
		if not counter in visited:
			counter += 1
		elif counter in visited2:
			counter += 1
	else:
		visited2.add(b[i])
ans = []
for i in range(n):
	ans.append(str(b[i]))
print(' '.join(ans))


n = int(input())
sp = list(range(n + 1))
prd = -1
b = []
a = []
for i in input().split():
	i = int(i)
	if i != prd:
		sp[i] = -1
	prd = i
	b += [i]
(pr, k) = (1, 0)
while pr:
	if sp[k] != -1:
		a += [sp[k]]
		k += 1
		pr = 0
	else:
		k += 1
for i in range(1, n):
	if b[i - 1] != b[i]:
		a += [b[i - 1]]
	else:
		pr = 1
		while pr:
			if sp[k] != -1:
				a += [sp[k]]
				k += 1
				pr = 0
			else:
				k += 1
print(*a)


n = int(input())
a = list(map(int, input().split()))
c = [0] * 1000001
for i in a:
	c[i] += 1
p = 0
q = []
sol = []
t = [0] * 1000001
for i in range(n + 1):
	if c[i] == 0:
		continue
	while c[i]:
		if q:
			c[i] -= 1
			sol.append(q[0])
			t[q[0]] += 1
			q.pop(0)
		else:
			while c[p] or t[p]:
				p += 1
			t[p] += 1
			sol.append(p)
			p += 1
			c[i] -= 1
	q.append(i)
print(*sol)


n = int(input())
aarr = list(map(int, input().split()))
tovisit = {t: 0 for t in range(aarr[-1] + 1)}
for k in aarr:
	tovisit[k] += 1
b = []
transit = []
i = 0
flag = True
for t in aarr:
	if t > i + 1:
		flag = False
		print(-1)
		break
	if transit:
		b.append(transit[0])
		del transit[0]
		tovisit[t] -= 1
		if tovisit[t] == 0 and t < i:
			transit.append(t)
		continue
	while i < aarr[-1] + 1 and tovisit[i]:
		i += 1
	b.append(i)
	i += 1
	tovisit[t] -= 1
	if tovisit[t] == 0 and t < i:
		transit.append(t)
if flag:
	print(*b)


n = int(input())
l = list(map(int, input().split()))
d = {}
l1 = [0] * (10 ** 5 + 1)
cnt = 0
l3 = []
for i in l:
	if i not in d:
		d[i] = 0
for i in range(len(l1)):
	if i in d:
		continue
	else:
		l1[i] = 1
l2 = []
for i in range(len(l1)):
	if l1[i] != 0:
		l2.append(i)
	else:
		l3.append(i)
(j, z) = (0, 0)
l4 = []
for i in range(len(l)):
	if l[i] > l3[j]:
		l4.append(l3[j])
		j += 1
	else:
		l4.append(l2[z])
		z += 1
print(*l4)


from fractions import Fraction
import bisect
import os
import io
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
from queue import Queue

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

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

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)))
t = 1
for _ in range(t):
	n = iinput()
	a = rlinput()
	a = [0] + a
	b = [-1] * (n + 1)
	mex = [False] * (int(100000.0) + 3)
	for i in range(1, n + 1):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			mex[a[i]] = True
	mex[0] = True
	curr = 0
	for i in range(1, n + 1):
		while mex[curr]:
			curr += 1
		if b[i] == -1:
			b[i] = curr
			mex[curr] = True
	print(*b[1:])


n = int(input())
arr = list(map(int, input().split()))
flag = 0
vis = [0] * (10 ** 6 + 1)
for i in range(n):
	if arr[i] > i + 1:
		flag = 1
	vis[arr[i]] = 1
if flag == 1:
	print(-1)
	quit()
b = [-1] * n
for i in range(1, n):
	if arr[i - 1] != arr[i]:
		b[i] = arr[i - 1]
not_vis = []
for i in range(10 ** 6 + 1):
	if vis[i] == 0:
		not_vis.append(i)
j = 0
for i in range(n):
	if b[i] == -1:
		b[i] = not_vis[j]
		j += 1
print(*b)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	n = int(input())
	ar = inpt()
	d = {}
	for i in ar:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	b = []
	j = 0
	temp = {}
	for i in range(n):
		bl = False
		if i != 0 and ar[i] != ar[i - 1]:
			for k in temp.keys():
				if k not in d:
					bl = True
					b.append(k)
					temp.pop(k)
					d[ar[i]] -= 1
					if d[ar[i]] == 0:
						d.pop(ar[i])
					break
		if bl == False:
			while j in d:
				temp[j] = True
				j += 1
			b.append(j)
			d[ar[i]] -= 1
			if d[ar[i]] == 0:
				d.pop(ar[i])
			j += 1
	for i in b:
		print(i, end=' ')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


n = int(input())
a = list(map(int, input().split()))
s1 = set(a)
s2 = set()
i = 0
c = 0
x = 0
lst = []
f = 1
while i < n:
	miss = a[i]
	if c == miss and x not in s1 and (x not in s2):
		lst.append(x)
		s2.add(x)
		x += 1
		i += 1
	elif c == miss and (x in s1 or x in s2):
		x += 1
	elif c != miss:
		lst.append(c)
		s2.add(c)
		i += 1
		while c in s2:
			c += 1
		if c != miss:
			f = 0
			break
if f == 1:
	print(*lst)
else:
	print(-1)


n = int(input())
l = list(map(int, input().split()))
from collections import Counter, defaultdict
if l[0] > 1:
	print(-1)
else:
	ans = True
	l2 = []
	i = 0
	d = defaultdict(int)
	l1 = [0] * n
	l3 = []
	l4 = []
	x = 0
	y = 0
	for i in range(n):
		if l[i] > i + 1:
			ans = False
		if d[l[i]] == 0:
			if i == 0 and l[i] == 0:
				l3.append(0)
			elif i == 0 and l[i] == 1:
				l1[i] = 0
			else:
				l1[i] = l[i - 1]
			l2.append(l[i])
			d[l[i]] += 1
		else:
			l3.append(i)
	for i in range(1, n + 2):
		if d[i] == 0:
			l4.append(i)
	j = 0
	for i in l3:
		if j != len(l4):
			l1[i] = l4[j]
			j += 1
		else:
			l1[i] = l4[-1]
	if ans == True:
		print(*l1)
	else:
		print(-1)


n = int(input())
lst = [int(i) for i in input().split()]
a = [-1] * n
visited = [-1] * 100001
flag = 0
for i in range(n):
	if lst[i] > i + 1:
		flag = 1
		break
	visited[lst[i]] = 1
not_v = list()
for i in range(100001):
	if visited[i] == -1:
		not_v.append(i)
for i in range(1, n):
	if lst[i] != lst[i - 1]:
		a[i] = lst[i - 1]
j = 0
for i in range(n):
	if a[i] == -1:
		a[i] = not_v[j]
		j += 1
print(*a)


import random

def fast(arr):
	result = [-1 for _ in arr]
	used = set()
	seen = set()
	prev = None
	for (i, elem) in enumerate(arr):
		if elem > i + 1:
			return None
		if i == 0:
			prev = elem
			seen.add(elem)
		elif elem not in seen:
			seen.add(elem)
			result[i] = prev
			used.add(prev)
			prev = elem
	ctr = 0
	for (i, elem) in enumerate(result):
		if elem == -1:
			while ctr in used or ctr == arr[i] or ctr in seen:
				ctr += 1
			result[i] = ctr
			used.add(ctr)
	return result

def main():
	n = int(input())
	arr = [int(x) for x in input().split()]
	result = fast(arr)
	if result is None:
		print(-1)
	else:
		print(' '.join((str(x) for x in result)))

def MEX(arr):
	ctr = 0
	while ctr in arr:
		ctr += 1
	return ctr

def check(arr, result):
	for i in range(len(arr)):
		print(i, arr[i], result[:i + 1], MEX(result[:i + 1]))
		if arr[i] != MEX(result[:i + 1]):
			return False
	return True

def test():
	arr = [0]
	result = fast(arr)
	print(result)
	print(check(arr, result))

def randomTest():
	t = 100
	for i in range(1, t + 1):
		n = random.randint(1, 10 ** 5)
		arr = sorted([random.randint(1, n) for _ in range(n)])
		print(i)
		result = fast(arr)
		if result is None:
			continue
main()


n = int(input())
A = [int(x) for x in input().split()]
rs = set(A)
mx = -1
p = -1
ans = []
for a in A:
	if p >= 0 and p != a:
		ans.append(p)
		if p == mx + 1:
			mx += 1
	else:
		mx += 1
		while mx in rs:
			mx += 1
		ans.append(mx)
	if mx + 1 < a:
		print(-1)
		break
	p = a
print(*ans)


n = int(input())
a = list(map(int, input().split()))
ans = [-1] * n
for index in range(1, n):
	if a[index] != a[index - 1]:
		ans[index] = a[index - 1]
not_to_be_included = set(a)
init = 0
for index in range(n):
	if ans[index] == -1:
		while init in not_to_be_included:
			init += 1
		ans[index] = init
		init += 1
print(*ans)


n = int(input())
ans = [-1] * n
se = set()
lis = list(map(int, input().split()))
length = len(lis)
for i in range(length - 1, 0, -1):
	if lis[i - 1] != lis[i]:
		ans[i] = lis[i - 1]
		se.add(lis[i - 1])
if lis[0] > 1:
	print(-1)
	exit()
i = 0
se.add(lis[-1])
j = 0
while True:
	if j == length:
		break
	if i in se:
		i += 1
		continue
	if ans[j] != -1:
		j += 1
		continue
	ans[j] = i
	j += 1
	i += 1
for i in ans:
	print(i, end=' ')


from sys import stdin, stdout
from sys import maxsize

def solve():
	pass
test = 1
for t in range(0, test):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = set(a)
	avail = []
	for i in range(10 * n):
		if not i in c:
			avail.append(i)
	b = []
	temp = a[0]
	j = 0
	m = a[0]
	for i in range(n):
		if temp != a[i]:
			if m + 1 < a[i] and temp < m:
				break
			if temp == m + 1 and a[i] > temp + 1:
				break
			b.append(temp)
			m = max(m, temp)
			(temp, z) = (a[i], i)
		else:
			z = avail[j]
			b.append(z)
			m = z
			j += 1
	if len(b) == n:
		for el in b:
			print(el, end=' ')
	else:
		print(-1)


arr_len = int(input())
arr = list(map(int, input().split()))
res = [-1]
for i in range(arr_len - 1):
	if arr[i] != arr[i + 1]:
		res.append(arr[i])
	else:
		res.append(-1)
low = 0
arr_set = set(arr)
for i in range(arr_len):
	if res[i] == -1:
		while low in arr_set:
			low += 1
		res[i] = low
		low += 1
for x in res:
	print(x, end=' ')
print()


import sys
input = sys.stdin.readline
import heapq as hp
N = int(input())
A = list(map(int, input().split()))
dic = {}
canuse = [True] * (N + 2)
for (i, a) in enumerate(A):
	dic[a] = i
	canuse[a] = False
q = []
for i in range(N + 1):
	if canuse[i]:
		hp.heappush(q, i)
ans = []
for (i, a) in enumerate(A):
	b = hp.heappop(q)
	ans.append(str(b))
	if dic[a] == i:
		hp.heappush(q, a)
print(' '.join(ans))


def getN():
	return int(input())

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

def getList():
	return list(map(int, input().split()))
from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
INF = 10 ** 17
MOD = 1000000007
from fractions import *

def inverse(f):
	return 1 / f

def make_next(n, nums):
	imos = [0 for i in range(n)]
	for (i, num) in enumerate(nums):
		if num > i:
			imos[0] += 1
		else:
			imos[i - num] += 1
		if i + num + 1 < n:
			imos[i + num + 1] -= 1
	nx = []
	tmp = 0
	for im in imos:
		tmp += im
		nx.append(tmp)
	return nx

def mantan_check(n, nums):
	if sum(nums) == n ** 2:
		return True
	else:
		return False

def knapsack(tree, vx, l):
	dp = [0 for i in range(l + 1)]
	while True:
		dpcp = copy.copy(dp)
		(v, w) = tree[vx - 1]
		for (i, d) in enumerate(dp):
			if w + i < l + 1:
				if dpcp[w + i] < v + d:
					dpcp[w + i] = v + d
		dp = copy.copy(dpcp)
		vx //= 2
		dp = dpcp
		if vx == 0:
			break
	return max(dp)

def solve():
	n = getN()
	nums = getList()
	ans = [-1 for i in range(n)]
	prev = 0
	used = [0 for i in range(n + 10)]
	for (i, num) in enumerate(nums):
		if num != prev:
			ans[i] = prev
			used[prev] = 1
			prev = num
	used[nums[-1]] = 1
	used_idx = 0
	for i in range(n):
		if ans[i] == -1:
			while True:
				if used[used_idx] == 0:
					ans[i] = used_idx
					used_idx += 1
					break
				used_idx += 1
	print(*ans)

def main():
	n = getN()
	for _ in range(n):
		solve()
solve()


from collections import deque
n = int(input())
bb = ''
c = [0 for j in range(n + 1)]
a = input().split(' ')
for j in range(n):
	a[j] = int(a[j])
	c[a[j]] = 1
b = [0 for j in range(n)]
k = 0
for j in range(n):
	if j == 0 or a[j] == a[j - 1]:
		while c[k] != 0:
			k += 1
		b[j] = k
		k += 1
	else:
		b[j] = a[j - 1]
for j in range(len(b)):
	bb += str(b[j]) + ' '
print(bb)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

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

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
n = iinp()
arr = lmp()
chk = l1d(n + 1, True)
ansl = l1d(n, -1)
for i in range(n - 1):
	if arr[i + 1] != arr[i]:
		ansl[i + 1] = arr[i]
		chk[arr[i]] = False
chk[arr[-1]] = False
j = 0
for i in range(n):
	if ansl[i] == -1:
		while not chk[j]:
			j += 1
		ansl[i] = j
		chk[j] = False
print(*ansl)


maxn = 10 ** 6 + 5
vis = [False for i in range(maxn)]
n = int(input())
arr = list(map(int, input().split()))
for i in arr:
	vis[i] = True
ans = []
cnt = 0
for i in range(n):
	if i != 0:
		if arr[i] == arr[i - 1]:
			while vis[cnt]:
				cnt += 1
			vis[cnt] = True
			ans.append(cnt)
		else:
			ans.append(arr[i - 1])
	else:
		while vis[cnt]:
			cnt += 1
		ans.append(cnt)
		vis[cnt] = True
print(*ans)


import sys
import collections as cc
import bisect as bi
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
ans = [-1] * n
temp = []
visi = [0] * (n + 1)
visi[l[-1]] = 1
for i in range(n - 1, 0, -1):
	if l[i] != l[i - 1]:
		ans[i] = l[i - 1]
		visi[l[i - 1]] = 1
j = 0
for i in range(n):
	if ans[i] == -1:
		while visi[j] == 1:
			j += 1
		ans[i] = j
		j += 1
print(*ans)


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
visit = [0] * 1000001
visit[a[0]] = 1
for j in range(1, n):
	if a[j] != a[j - 1]:
		b[j] = a[j - 1]
	visit[a[j]] = 1
start = 0
for j in range(n):
	if b[j] == -1:
		while visit[start] == 1:
			start += 1
		b[j] = start
		visit[start] = 1
		start += 1
		if start > 1000000:
			break
if b.count(-1) != 0:
	print(-1)
else:
	print(*b)


from sys import *
from heapq import *
input = stdin.readline
n = int(input())
a = [int(x) for x in input().split()]
b = list(range(1, n + 1))
chk = [0] * (n + 1)
flag = 0
q = []
for x in range(n):
	if a[x] > b[x]:
		flag = -1
	chk[a[x]] += 1
if flag == -1:
	print(-1)
	exit()
for x in range(n + 1):
	if chk[x] == 0:
		heappush(q, x)
t = heappop(q)
print(t, end=' ')
for x in range(1, n):
	if a[x - 1] != a[x]:
		print(a[x - 1], end=' ')
	else:
		t = heappop(q)
		print(t, end=' ')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10, 6)))
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
t = 1
for _ in range(t):
	n = L()[0]
	l = L()
	b = [-1] * n
	vis = [0] * (n + 1)
	k = 0
	vis[l[-1]] = 1
	for i in range(n - 1, 0, -1):
		if l[i] != l[i - 1]:
			b[i] = l[i - 1]
			vis[l[i - 1]] = 1
	for i in range(n):
		if b[i] == -1:
			while vis[k] == 1:
				k += 1
			b[i] = k
			k += 1
	print(*b)


n = int(input())
a = list(map(int, input().split()))
b = set(a)
(k, t) = (0, 0)
not_in_set = []
for j in range(1, n + 1):
	if j not in b:
		not_in_set.append(j)
for i in range(n):
	if a[i] > i + 1:
		print(-1)
		break
	elif a[i] != k:
		print(k, end=' ')
		k = a[i]
	else:
		print(not_in_set[t], end=' ')
		t += 1


import sys
from collections import defaultdict as dd
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
n = int(input())
a = list(map(int, input().split()))
q = [-1] * n
for i in range(1, n):
	if a[i] != a[i - 1]:
		q[i] = a[i - 1]
w = []
j = 0
for i in a:
	while j < n + 1 and j < i:
		w.append(j)
		j += 1
	if j == i:
		j += 1
w += [i for i in range(a[-1] + 1, 2 * n)]
k = 0
for i in range(n):
	if q[i] == -1:
		q[i] = w[k]
		k += 1
print(*q)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		if any((i < c for (i, c) in enumerate(a, 1))):
			rr.append(-1)
		else:
			a.append(0)
			s = set(a)
			k = 0
			r = []
			for (i, c) in enumerate(a[:-1]):
				if c != a[i - 1]:
					r.append(a[i - 1])
				else:
					while k in s:
						k += 1
					r.append(k)
					k += 1
			rr.append(JA(r, ' '))
	return JA(rr, '\n')
print(main())


from collections import defaultdict
n = int(input())
arr = [int(i) for i in input().split()]
b = [-1] * n
avail = defaultdict(int)
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		b[i] = arr[i - 1]
		avail[b[i]] = 1
for i in range(n):
	avail[arr[i]] = 1
start = 0
for i in range(n):
	if b[i] == -1:
		while avail[start] == 1:
			start += 1
		b[i] = start
		avail[start] = 1
print(*b)


import sys
input = sys.stdin.readline
n = int(input())
A = list(map(int, input().split()))
for i in range(n):
	if A[i] > i + 1:
		print(-1)
		sys.exit()
from collections import Counter
C = Counter(A)
ANS = []
now = 0
while now in C:
	now += 1
for i in range(n):
	for x in sorted([now, A[i - 1]]):
		if x in C:
			continue
		ANS.append(x)
		break
	C[x] += 1 << 31
	C[A[i]] -= 1
	if C[A[i]] == 0:
		del C[A[i]]
	while now in C:
		now += 1
print(*ANS)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

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

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	mx = 10 ** 6
	use = [False] * mx
	for (i, a) in enumerate(aa[1:], 1):
		if a > i:
			return [-1]
		use[a] = True
	bb = []
	j = 0
	for i in range(1, n + 1):
		if aa[i] == aa[i - 1]:
			while use[j]:
				j += 1
			use[j] = True
			bb.append(j)
		else:
			bb.append(aa[i - 1])
			use[aa[i - 1]] = True
	return bb
n = II()
aa = [0] + LI()
print(*main())


import heapq
import collections
n = int(input())
a = list(map(int, input().split()))
ctr = collections.Counter(a)
Q = [i for i in range(10 ** 6 + 1) if ctr.get(i) == None]
heapq.heapify(Q)
b = []
ctr = sorted(ctr.items())
for i in range(n):
	b.append(heapq.heappop(Q))
	(k, v) = ctr[0]
	if a[i] == k:
		v -= 1
		if v == 0:
			heapq.heappush(Q, k)
			ctr.pop(0)
		else:
			ctr[0] = (k, v)
	else:
		print(-1)
		break
else:
	print(' '.join(map(str, b)))


from sys import stdin, stdout
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().strip().split(' ')))
p = True
for i in range(len(arr)):
	if arr[i] > i + 1:
		p = False
if not p:
	stdout.write('-1\n')
else:
	arr += [arr[-1] + 1]
	av = [1 for i in range(len(arr) + 10)]
	tarr = [-1 for i in range(len(arr))]
	for i in range(1, len(arr)):
		if arr[i] != arr[i - 1]:
			tarr[i] = arr[i - 1]
			av[arr[i - 1]] = 0
	ctr = 0
	for i in range(len(tarr)):
		if tarr[i] == -1:
			while av[ctr] == 0:
				ctr += 1
			tarr[i] = ctr
			ctr += 1
	stdout.write(' '.join(list(map(str, tarr[:-1]))) + '\n')


n = int(input())
a = list(map(int, input().split()))
l = []
r = []
s1 = set(a)
s2 = set([int(x) for x in range(n + 2)])
s3 = s2.difference(s1)
r = list(s3)
r.sort()
l.append(r[0])
r.remove(r[0])
for i in range(1, n):
	if a[i - 1] != a[i]:
		l.append(a[i - 1])
	else:
		l.append(r[0])
		r.remove(r[0])
print(*l)


n = int(input())
l = [int(x) for x in input().split()]
if l[0] > 1 or l[-1] > n:
	print(-1)
else:
	flag = 0
	dup = 0
	for i in range(n):
		if l[i] - i > 1:
			flag = 1
			break
	if flag == 1:
		print(-1)
	else:
		s1 = set(l)
		s2 = set([int(x) for x in range(0, n + 2)])
		s3 = s2.difference(s1)
		l1 = list(s3)
		l1.sort()
		ans = []
		if l[0] == 0:
			ans.append(l1.pop(0))
		else:
			l1.pop(0)
			ans.append(0)
		prev = l[0]
		for i in range(1, n):
			if l[i] == prev:
				ans.append(l1.pop(0))
			else:
				ans.append(prev)
				prev = l[i]
		print(*ans)


from heapq import *
for t in range(1):
	n = int(input().strip())
	s = list(map(int, input().strip().split()))[:n]
	res = 1
	for i in range(n - 1):
		if s[i] > i + 1 or s[i + 1] < s[i]:
			res = -1
	if res == -1:
		print(-1)
		break
	used = list(set(s)) + [n + 1] * n
	rest = list(set(range(2 * n)) - set(s))
	heapify(rest)
	heapify(used)
	startrest = 0
	res = []
	for j in s:
		if j <= used[0]:
			res.append(heappop(rest))
		else:
			res.append(heappop(used))
	print(*res)


import heapq
n = int(input())
a = [int(e) for e in input().split()]
used = set(a)
prior_queue = [i for i in range(n + 1) if i not in used]
heapq.heapify(prior_queue)
res_arr = []
flag = True
for i in range(len(a)):
	if a[i] >= (i + 1) * 2:
		flag = False
		break
	cur_elem = heapq.heappop(prior_queue)
	res_arr.append(cur_elem)
	if i + 1 < len(a) and a[i] < a[i + 1]:
		heapq.heappush(prior_queue, a[i])
if flag:
	for e in res_arr:
		print(e, end=' ')
else:
	print(-1, end='')
print()


import math
import sys
import collections
from collections import defaultdict
from sys import stdin, stdout
n = int(input())
arr = list(map(int, input().split()))
temp = set(arr)
(a, b) = (0, 1)
ans = []
for i in range(n):
	if arr[i] != a:
		ans.append(a)
		if arr[i] == b:
			b += 1
	else:
		while b in temp:
			b += 1
		ans.append(b)
		b += 1
	a = arr[i]
print(*ans)


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

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

def IO():
	return stdin.readline()

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count

def solve():
	n = II()
	a = L()
	b = [-1] * n
	visited = [0] * (10 ** 6 + 1)
	visited[a[0]] = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
		visited[a[i]] = 1
	avail = []
	for i in range(10 ** 6 + 1):
		if visited[i] == 0:
			avail.append(i)
	k = 0
	for i in range(n):
		if b[i] == -1:
			b[i] = avail[k]
			k += 1
	print(*b)
solve()


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))
n = I()
a = IL()
b = [-1 for x in a]
flag = 1
m = {}
for i in range(n):
	m[a[i]] = i + 1
for x in m:
	if m[x] < n:
		b[m[x]] = x
c = []
for i in range(2 * n + 1):
	if i in m:
		continue
	c.append(i)
c.sort()
x = 0
i = 0
j = 0
while i < n and j < 2 * n:
	if b[i] != -1:
		i += 1
		continue
	b[i] = c[j]
	j += 1
	i += 1
check = [-1 for i in a]
temp = 0
mp = {}
for i in range(n):
	mp[b[i]] = 1
	if b[i] == temp:
		while temp in mp and mp[temp] != 0:
			temp += 1
	check[i] = temp
for i in range(n):
	if check[i] != a[i]:
		flag = 0
		break
if flag == 1:
	for bb in b:
		print(bb, end=' ')
	print()
else:
	print(-1)


n = int(input().strip())
l = [int(a) for a in input().strip().split()]
ans = [0] * n
done = {}
index = {}
for i in range(n):
	done[l[i]] = 1
for i in range(1, n):
	if l[i] != l[i - 1]:
		ans[i] = l[i - 1]
		index[i] = 1
j = 0
for i in range(n):
	if i in index.keys():
		continue
	while j in done.keys():
		j += 1
	ans[i] = j
	j += 1
print(*ans)


import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = [-1] * N
if a[0]:
	res[0] = 0
for i in range(N - 1):
	if a[i + 1] > a[i]:
		res[i + 1] = a[i]
s = sorted(set([x for x in range(N + 1)]) - set(a) - set(res), reverse=True)
for i in range(N):
	if res[i] == -1:
		res[i] = s.pop()
print(*res)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
n = inputnum()
a = inputlist()
b = [-1] * n
c = [False] * 1000000
c[a[0]] = True
for i in range(1, n):
	c[a[i]] = True
	if a[i] > a[i - 1]:
		b[i] = a[i - 1]
m = 0
for i in range(n):
	while c[m] == True:
		m += 1
	if b[i] == -1:
		b[i] = m
		c[m] = True
print(*b)


n = int(input())
a = list(map(int, input().split()))
p = 0
q = 1
t = set(a)
for i in a:
	if i == p:
		while q in t:
			q += 1
		print(q, end=' ')
		q += 1
	else:
		print(p, end=' ')
		p = i


from sys import stdin, stdout
n = int(stdin.readline())
arr = list(map(int, stdin.readline().strip().split()))
if sorted(arr) != arr:
	print(-1)
else:
	flg = 0
	for i in range(n):
		if arr[i] - i > 1:
			flg = 1
			break
	if flg:
		print(-1)
	else:
		raj = dict()
		for i in range(n):
			raj[arr[i]] = 1
		x = -1
		ans = []
		for i in range(n):
			if i == 0:
				x = x + 1
				while x in raj:
					x += 1
				ans.append(x)
			elif arr[i - 1] != arr[i]:
				ans.append(arr[i - 1])
			else:
				x = x + 1
				while x in raj:
					x += 1
				ans.append(x)
		print(*ans)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

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

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def solve():
	n = int(inp())
	a = lis()
	m = max(a)
	for i in range(0, n):
		if i >= a[i] - 1:
			continue
		else:
			print(-1)
			return
	b = [-1] * n
	nta = [False] * (m + 1)
	for i in range(1, n):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
	s = list(set(b))
	for i in s:
		nta[i] = True
	if a[0] == 0:
		curr = 1
	else:
		curr = 0
	toadd = []
	for i in range(0, m + 1):
		if nta[i] == False:
			toadd.append(i)
	for i in range(m + 1, 10 ** 6 + 1):
		toadd.append(i)
	j = 0
	for i in range(0, n):
		if b[i] == -1:
			b[i] = toadd[j]
			j += 1
	print(*b)
testcase(1)


n = int(input())
l = list(map(int, input().split()))
m = l[-1] + 1
d = {}
s = set(l)
for i in l:
	if i in d:
		d[i] = d[i] + 1
	else:
		d[i] = 1
o = []
for i in range(0, m):
	if i in s:
		pass
	else:
		o.append(i)
o = o[::-1]
p = []
for i in l:
	if len(o) == 0:
		p.append(m)
		m = m + 1
		d[i] = d[i] - 1
		if d[i] == 0:
			o.append(i)
	else:
		x = o.pop()
		p.append(x)
		d[i] = d[i] - 1
		if d[i] == 0:
			o.append(i)
print(*p)


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	from heapq import heappop, heappush
	from collections import Counter
	n = int(input())
	a = list(map(int, input().split()))
	cnt = Counter(a)
	used = [0] * (2 * 10 ** 5)
	hq = [i for i in range(2 * 10 ** 5) if cnt[i] == 0]
	ans = []
	l = 0
	for (i, v) in enumerate(a):
		ans.append(heappop(hq))
		used[ans[-1]] = 1
		if not (all((used[j] for j in range(l, v))) and (not used[v])):
			print(-1)
			exit()
		l = v
		cnt[v] -= 1
		if cnt[v] == 0:
			heappush(hq, v)
	output(' '.join(map(str, ans)))
main()


MAX = 10 ** 6 // 2
n = int(input())
A = list(map(int, input().split(' ')))
A.append(0)
B = [-1] * n
excluded = sorted(list(set(range(0, n + 1)) - set(A)), reverse=True)
for i in range(n):
	if A[i] != A[i - 1]:
		B[i] = A[i - 1]
	else:
		B[i] = MAX if len(excluded) == 0 else excluded.pop()
print(*B)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
n = int(data())
arr = l()
for i in range(n):
	if arr[i] > i + 1:
		out(-1)
		exit()
c = C(arr)
answer = [-1] * n
m = 0
for i in range(n):
	if i > 0 and arr[i] != arr[i - 1]:
		answer[i] = arr[i - 1]
		m = max(arr[i], m)
	else:
		while c[m] > 0:
			m += 1
		answer[i] = m
		m += 1
	c[arr[i]] -= 1
out(*answer)


from collections import deque
N = int(input())
List = [int(x) for x in input().split()]
for i in range(N):
	if List[i] > i + 1:
		print(-1)
		exit()
Nahi = list(set(list(range(N + 1))).difference(set(List)))
Nahi.sort()
Ans = [Nahi[0]]
Added = deque()
Added.append(List[0])
index = 1
for i in range(1, N):
	if List[i] == List[i - 1]:
		if Added[-1] != List[i]:
			Added.append(List[i])
		Ans.append(Nahi[index])
		index += 1
	else:
		Ans.append(Added[0])
		Added.popleft()
		Added.append(List[i])
print(*Ans)


import sys, os, io
import math, bisect, operator
(inf, mod) = (float('inf'), 10 ** 9 + 7)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
Neo = lambda : list(map(int, input().split()))
(test,) = Neo()
n = test
A = Neo()
C = Counter(A)
B = []
for i in range(n + 1):
	if i not in C:
		B.append(i)
B.sort()
B = deque(B)
Ans = []
for i in A:
	Ans.append(B.popleft())
	C[i] -= 1
	if C[i] == 0:
		B.appendleft(i)
print(*Ans)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
import copy
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(x) for x in input().split()]

def fi():
	return int(input())

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

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

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

def bo(i):
	return ord(i) - ord('a')
from copy import *
from bisect import *
from itertools import permutations
t = 1
while t > 0:
	t -= 1
	n = fi()
	a = li()
	d = [0 for i in range(n)]
	s = set([i for i in range(n + 1)])
	p = s - set(a)
	s = list(s)
	s.sort()
	ff = {}
	mex = 0
	for i in range(n):
		if a[i] > i + 1:
			print(-1)
			exit(0)
	j = 0
	m = len(p)
	p = list(p)
	for i in range(n):
		if i > 0 and a[i] != a[i - 1]:
			print(a[i - 1], end=' ')
		elif j >= m:
			print(0, end=' ')
		else:
			print(p[j], end=' ')
			j += 1


from sys import stdin
input = stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
sa = set(a)
x = 0
for i in range(n):
	if b[i] == -1:
		while x in sa:
			x += 1
		b[i] = x
		x += 1
print(*b)


import sys
sys.setrecursionlimit(2 * 10 ** 5)
n = int(input())
l = [int(i) for i in input().split()]
check = [0] * (2 * 10 ** 5)
for i in l:
	check[i] = 1
ans = []
c = False
for i in range(n):
	if check[i] == 0:
		now = i
		c = True
		break
if not c:
	now = max(l) + 1
M = now
b = l[0]
for i in range(n):
	if b == l[i]:
		while now < n + 2 and check[now]:
			now += 1
		ans.append(now)
		check[now] = 1
		M = max(M, now)
	else:
		if now < b and check[b - 1]:
			if b - 1 == now:
				M = max(M, b)
				now = b
		ans.append(b)
		b = l[i]
	if M < l[i] - 1:
		print(-1)
		exit()
print(*ans)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in range(base ** n):
		s = [tb // base ** bt % base for bt in range(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, ls=None, init=True, index=1):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			if ls == None:
				self.stdin(inp_size, index=index)
			else:
				self.size = len(ls) + 1
				(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def dfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def bfs(self, x, func=lambda pr, prv, nx, dist: prv + dist, root_v=0):
		q = deque([x])
		v = [None] * self.size
		v[x] = root_v
		while q:
			c = q.popleft()
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = func(c, v[c], nb, d)
		return v

	def parent(self, x):
		return self.dfs(0, func=lambda pr, prv, nx, dist: pr, root_v=-1)

	def topological_sort(self, x):
		tps = []
		q = deque([x])
		v = [None] * self.size
		v[x] = 0
		while q:
			c = q.popleft()
			tps.append(c)
			for (nb, d) in self.edges[c]:
				if v[nb] == None:
					q.append(nb)
					v[nb] = 0
		return tps

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

	def __str__(self):
		return str(self.edges)

	def show(self):
		if all([all([d == 1 for (nd, d) in edge]) for edge in self.edges]):
			print([[nd for (nd, d) in edge] for edge in self.edges])
		else:
			print(self)

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))])

	def query_id(self, l, r):
		if r > self.size:
			r = self.size
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][max(0, r - (1 << N))])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][max(0, r - (1 << N))]):
			b = a
		return b

	def right_bound(self, pos, x):
		k = (self.size - pos).bit_length()
		for j in range(k)[::-1]:
			nx = pos + (1 << j)
			if nx < n and self.query(pos, nx + 1) <= x:
				pos += 1 << j
		return pos

	def left_bound(self, pos, x):
		k = pos.bit_length()
		for j in range(k)[::-1]:
			nx = pos - (1 << j)
			if 0 <= nx and self.query(nx, pos + 1) <= x:
				pos -= 1 << j
		return pos

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)
show_flg = False
show_flg = True
ans = 0
ans = 0
n = I()
a = LI()
ac = [a[0]]
m = [0] * (n + 2)
b = []
for i in range(n):
	m[a[n - 1 - i]] = n - 1 - i + 1
	if ac[-1] != a[i]:
		ac += [a[i]]
d = {i: j for (i, j) in zip(ac + [inf], ac[1:] + [inf] * 2)}
ac += [inf]
ac = ac[::-1]
s = set(ac)
q = []
for i in range(2 * n + 1)[::-1]:
	if i not in s:
		q += (i,)
mex = 0
j = 0
for i in range(n):
	if a[i] > ac[-1]:
		t = ac.pop()
	else:
		t = q.pop()
	b += (t,)
ans = b
print(*ans)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	l = list(map(int, input().split()))
	a = [0] * (10 ** 6 + 1)
	for i in range(n):
		if l[i] > i + 1:
			print(-1)
			return
		a[l[i]] = 1
	x = []
	for i in range(len(a)):
		if a[i] == 0:
			x.append(i)
	j = 1
	ans = [x[0]]
	for i in range(1, n):
		if l[i] == l[i - 1]:
			ans.append(x[j])
			if j != n - 1:
				j += 1
		else:
			ans.append(l[i - 1])
	print(*ans)
solution()


production = True
import sys, math

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = next_line.split()
		elif input_format == 4:
			formatted_input = (lambda x: [x[0], list(map(int, x[1:]))])(next_line.split())
		elif input_format == 5:
			formatted_input = (lambda x: [x[0], list(map(float, x[1:]))])(next_line.split())
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 1:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$')
		print(*args)

def solve():
	n = input(11)
	a = input(1)
	if a != sorted(a):
		out(-1)
		return
	y = set(a)
	p = []
	for i in range(3 * 10 ** 6, -1, -1):
		if i not in y:
			p.append(i)
	k = []
	log(a)
	for (i, j) in enumerate(a):
		log(i, j)
		k.append(p.pop())
		if i < n - 1 and j < a[i + 1]:
			p.append(j)
	log(k)
	out(k, 1)
	return
solve()


n = int(input())
A = [int(i) for i in input().split()]
for i in range(n):
	if A[i] > i + 1:
		print(-1)
		break
else:
	ans = [-1] * n
	visited = [False] * (n + 1)
	for i in range(1, n):
		if A[i] != A[i - 1]:
			ans[i] = A[i - 1]
			visited[A[i - 1]] = True
	visited[A[-1]] = True
	pointer = 0
	for i in range(n):
		if ans[i] == -1:
			while visited[pointer]:
				pointer += 1
			visited[pointer] = True
			ans[i] = pointer
print(*ans)


n = int(input())
a = list(map(int, input().split()))
se = set(range(n + 1)) - set(a)
li = list(se)
li.sort()
pre = 0
idx = 0
ans = []
for i in range(n):
	if a[i] > pre:
		ans.append(pre)
		if pre in se and idx < len(li) - 1:
			idx += 1
		pre = a[i]
	else:
		ans.append(li[idx])
		if idx < len(li) - 1:
			idx += 1
print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
n = set([i for i in range(t + 1)])
l = list(map(int, input().split()))
ss = set(l)
pp = list(n.difference(ss))
pp.sort()
for el in range(len(l)):
	if l[el] > el + 1:
		print(-1)
		exit()
b = [pp[0]]
c = 1
for el in range(1, len(l)):
	if l[el] > l[el - 1]:
		b.append(l[el - 1])
	else:
		b.append(pp[c])
		c += 1
print(*b)


n = int(input())
num = tuple(map(int, input().split()))
s = set(num)
ss = set()
prev = 0
m = 0
ans = [0] * n
for i in range(n):
	cur = num[i]
	if cur == prev:
		while m in s:
			m += 1
		ans[i] = m
		s.add(m)
		ss.add(m)
	else:
		ans[i] = prev
		s.add(prev)
		ss.add(prev)
		while prev in ss:
			prev += 1
		if prev != cur:
			print(-1)
			break
else:
	print(*ans)


def main():
	n = int(input())
	ar = list(map(int, input().split()))
	if n == 1:
		print((1, 0)[ar[0] > 0])
		return
	res = [-1] * n
	s = set(ar)
	mx = -1
	for i in range(1, n):
		if ar[i] > ar[i - 1]:
			res[i] = ar[i - 1]
			mx = max(mx, res[i])
	j = 0
	for i in range(n):
		if res[i] == -1:
			while j in s:
				j += 1
			res[i] = j
			mx = max(mx, j)
			j += 1
	if ar[n - 1] - mx > 1:
		print(-1)
		return
	for x in res:
		print(x, end=' ')
	print()
main()


import heapq
n = int(input())
(*arr,) = map(int, input().split())
first = {}
last = {}
for i in range(n):
	last[arr[i]] = i
big_number = max(arr) + 1
b = [-1] * n
used = set()
for i in range(n):
	if i == 0 or arr[i] != arr[i - 1]:
		last_idx = last[arr[i]]
		if last_idx != n - 1:
			b[last_idx + 1] = arr[i]
			used.add(arr[i])
used.add(arr[-1])
max_val = max(arr) + 1
l = arr[-1] - 1
l = 0
for i in range(n):
	if b[i] == -1:
		while l in used:
			l += 1
		b[i] = l
		l += 1
print(*b)


n = int(input())
ans = []
a = list(map(int, input().split()))
oset = set((i for i in range(2 * n + 1)))
aset = set(a)
iset = oset - aset
ilist = sorted(list(iset), reverse=True)
for j in range(n):
	ans.append(ilist[-1])
	de = a.pop(0)
	if len(a) and a[0] != de:
		ilist.pop(-1)
		ilist.append(de)
	else:
		ilist.pop(-1)
for kk in ans:
	print(kk, end=' ')


from sys import stdin, stdout
import sys
from math import *
n = int(input())
ar = list(map(int, input().split()))
ans = []
for i in range(n):
	if ar[i] > i + 1:
		print(-1)
		exit()
ans = [-1] * n
d = {}
for i in range(1, n):
	if ar[i] != ar[i - 1]:
		d[ar[i - 1]] = 1
		ans[i] = ar[i - 1]
d[ar[-1]] = 1
x = 0
for i in range(n):
	if ans[i] == -1:
		while 1:
			if d.get(x) == None:
				ans[i] = x
				x += 1
				break
			x += 1
print(*ans)


n = int(input())
dp = list(map(int, input().split()))
l = []
u = []
for i in range(0, n + 1):
	l.append(0)
for i in range(0, n):
	l[dp[i]] = 1
for i in range(0, n + 1):
	if l[i] == 0:
		u.append(i)
j = 0
print(u[j], end=' ')
j += 1
for i in range(1, n):
	if dp[i - 1] != dp[i]:
		print(dp[i - 1], end=' ')
	else:
		print(u[j], end=' ')
		j += 1


a = int(input())
b = list(map(int, input().split()))
c = [0] * 1000001
d = [-1] * 1000001
for i in range(1, a):
	if b[i] != b[i - 1]:
		d[i] = b[i - 1]
		c[b[i - 1]] = 1
m = 0
c[b[a - 1]] = 1
for i in range(a):
	while c[m]:
		m += 1
	if d[i] == -1:
		d[i] = m
		c[m] = 1
	print(d[i], end=' ')


n = int(input())
s = list(map(int, input().split()))
stack = list()
for i in range(n, s[-1], -1):
	stack.append(i)
for i in range(len(s) - 1, 0, -1):
	if s[i] == s[i - 1]:
		continue
	else:
		for j in range(s[i] - 1, s[i - 1], -1):
			stack.append(j)
fin_list = list()
if s[0] == 1:
	stack.append(0)
for i in range(len(s) - 1):
	if s[i] != s[i + 1]:
		curr_val = stack.pop(-1)
		fin_list.append(curr_val)
		stack.append(s[i])
	else:
		curr_val = stack.pop(-1)
		fin_list.append(curr_val)
curr_val = stack.pop(-1)
fin_list.append(curr_val)
print(*fin_list)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(input())
P = 1000000007

def main():
	n = I()
	arr = L()
	val = set(arr)
	(p, q) = (0, 1)
	for i in range(n):
		if arr[i] == p:
			while q in val:
				q += 1
			print(q, end=' ')
			q += 1
		else:
			print(p, end=' ')
			p = arr[i]
main()


n = int(input())
a = list(map(int, input().split()))
l = [0] * (n + 2)
for elem in a:
	l[elem] = 1
not_present = []
for i in range(n + 2):
	if l[i] == 0:
		not_present.append(i)
j = 0
b = []
for i in range(n):
	if i == 0:
		b.append(not_present[j])
		j += 1
	elif a[i] != a[i - 1]:
		b.append(a[i - 1])
	else:
		b.append(not_present[j])
		j += 1
print(*b)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
d = set(a)
done = {}
m = 0
while m in d:
	m += 1
b[0] = m
done[b[0]] = 1
for i in range(1, n):
	if a[i] == a[i - 1]:
		curr = m + 1
		while curr in d:
			curr += 1
		b[i] = curr
		done[b[i]] = 1
		m = max(m, b[i])
	else:
		if a[i - 1] not in done:
			b[i] = a[i - 1]
		else:
			curr = m + 1
			while curr in d:
				curr += 1
			b[i] = curr
		done[b[i]] = 1
		m = max(m, b[i])
print(*b)


import sys
input = sys.stdin.readline

def main():
	N = int(input())
	A = [int(x) for x in input().split()]
	seta = set(A)
	mex = 0
	ans = []
	ma = 0
	for (i, a) in enumerate(A):
		if a == mex:
			if len(ans) == 0:
				for j in range(1, N + 1):
					if j not in seta:
						ans.append(j)
						ma = max(ma, j)
						break
				else:
					print(-1)
					return
			else:
				for j in range(max(mex, ma) + 1, N + 1):
					if j not in seta:
						ans.append(j)
						ma = max(ma, j)
						break
				else:
					print(-1)
					return
		else:
			ans.append(mex)
			ma = max(ma, mex)
			mex = a
	print(*ans)
main()


n = int(input())
arr = list(map(int, input().strip().split()))[:n]
from collections import defaultdict
store = defaultdict(int)
ans = [-1] * n
for num in arr:
	store[num] = True
for i in range(1, n):
	if arr[i] > i + 1:
		print(-1)
		exit(0)
	elif i > 0 and arr[i] != arr[i - 1]:
		ans[i] = arr[i - 1]
		store[arr[i - 1]] = True
low = 0
for i in range(n):
	if ans[i] == -1:
		while store[low] == True:
			low += 1
		ans[i] = low
		store[low] = True
	print(ans[i], end=' ')
print()


n = int(input())
a = list(map(int, input().split()))
l = [0] * 1000001
for i in a:
	l[i] = 1
(s, np, f, j, k) = ([], [], [], 0, 0)
for i in range(0, 1000001):
	if l[i] == 0:
		np.append(i)
w = len(np)
fg = 0
for i in range(0, n):
	if a[i] > i + 1:
		fg = 1
		break
if fg == 1:
	print(-1)
else:
	for i in range(0, n):
		b = len(s)
		if j < b and k < w:
			if s[j] < np[k] and s[j] != a[i]:
				f.append(s[j])
				j += 1
			else:
				f.append(np[k])
				k += 1
		elif k >= w and j < b:
			if s[j] == a[i]:
				fg = 1
				break
			else:
				f.append(s[j])
				j += 1
		elif k < w and j >= b:
			f.append(np[k])
			k += 1
		else:
			fg = 1
			break
		if b != 0:
			if s[b - 1] != a[i]:
				s.append(a[i])
		else:
			s.append(a[i])
if fg == 1:
	print(-1)
else:
	print(' '.join((str(a) for a in f)))


import os
import sys, math
from io import BytesIO, IOBase

def main():
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	for i in range(n):
		if i + 1 < l[i]:
			print(-1)
			return
		s.add(l[i])
	b = []
	v = 0
	chk = True
	for i in range(n):
		while v in s:
			v += 1
		if i > 0 and l[i] != l[i - 1]:
			b.append(l[i - 1])
		else:
			b.append(v)
			v += 1
	for c in b:
		print(c, end=' ')
	print()
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

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

def ar(element, size):
	return [element for i in range(size)]

def yes():
	print('Yes')

def no():
	print('No')
Testcase = 1
for _ in range(Testcase):
	n = inin()
	a = inar()
	i = 1
	s = set(a[:])
	d = [-1 for i in range(n)]
	while i < n:
		if a[i] != a[i - 1]:
			d[i] = a[i - 1]
		i += 1
	a = set([i for i in range(0, 100009)])
	a = a.difference(s)
	for i in range(n):
		if d[i] == -1:
			d[i] = a.pop()
	print(*d)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

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

def oint():
	return int(input())
n = oint()
a = list(rint())
ans = [-1] * n
used = set()
for i in range(1, n):
	if a[i - 1] == a[i]:
		continue
	ans[i] = a[i - 1]
	used.add(ans[i])
used.add(a[-1])
cur = 0
for i in range(n):
	if ans[i] != -1:
		continue
	for j in range(cur, 10 ** 9, 1):
		if j not in used:
			ans[i] = j
			cur = j + 1
			break
print(*ans)


n = int(input())
a = list(map(int, input().split()))

def mex(n, a):
	if a[0] > 1:
		print(-1)
		return
	unuse = list(range(2 * 10 ** 5 + 3, -1, -1))
	used = set(a)
	unused = [t for t in unuse if t not in used]
	ret = []
	i = 0
	while i < len(a):
		if i - 1 >= 0 and a[i] != a[i - 1]:
			ret.append(a[i - 1])
			if unused[-1] <= a[i]:
				print(-1)
				return
		else:
			ret.append(unused.pop())
		i += 1
	print(' '.join(map(str, ret)))
mex(n, a)


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
l = list(map(int, input().split()))
result = [-1] * n
cant = [0] * (n * 2)
cant[l[-1]] = 1
for i in range(1, n):
	if l[i] != l[i - 1]:
		result[i] = l[i - 1]
		cant[result[i]] = 1
i = 0
for j in range(n):
	while cant[i]:
		i += 1
	if result[j] == -1:
		result[j] = i
		cant[i] = 1
print(' '.join([str(e) for e in result]))


import math
n = int(input())
array = list(map(int, input().split()))
dict_num = {}
ans = 0
for i in range(n):
	if array[i] > i + 1 or (i + 1 < n and array[i] > array[i + 1]):
		ans = -1
		break
	dict_num[array[i]] = 0
if ans == -1:
	print(-1)
else:
	stored = []
	not_stored = []
	for i in range(n, -1, -1):
		if i in dict_num:
			stored.append(i)
		else:
			not_stored.append(i)
	ans = []
	for i in range(n):
		if ans == []:
			ans.append(not_stored[-1])
			not_stored.pop()
		else:
			new = 0
			if dict_num[stored[-1]] == 1:
				new = stored[-1]
				stored.pop()
			else:
				new = not_stored.pop()
			ans.append(new)
		if i + 1 < n:
			if array[i] != array[i + 1]:
				dict_num[array[i]] = 1
	print(*ans)


n = int(input())
a = list(map(int, input().split()))
m = set(a)
u = [i for i in range(n + 1) if i not in m]
if a[0] not in [0, 1]:
	print(-1)
	exit()
b = [u.pop(0)]
for i in range(1, n):
	if a[i] != a[i - 1]:
		b.append(a[i - 1])
	else:
		b.append(u.pop(0))
print(*b)


import sys
input = sys.stdin.buffer.readline
n = int(input())
(*a,) = map(int, input().split())
inA = [0] * (n + 5)
for x in a:
	inA[x] += 1
keep = [0]
ma = 0
ans = []
for i in range(n):
	if keep and (not inA[keep[0]]):
		ans.append(keep.pop(0))
	else:
		ma += 1
		while inA[ma]:
			keep.append(ma)
			ma += 1
		ans.append(ma)
	if ma + 1 < a[i]:
		print(-1)
		exit()
	inA[a[i]] -= 1
print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')

def main():
	n = N()
	arr = RLL()
	dic = defaultdict(int)
	res = [-1] * n
	if arr[0] == 1:
		res[0] = 0
	for i in range(n):
		dic[arr[i]] = max(dic[arr[i]], i)
	for i in dic:
		if dic[i] + 1 < n:
			res[dic[i] + 1] = i
	now = 1
	for i in range(n):
		if res[i] == -1:
			while now in dic:
				now += 1
			res[i] = now
			now += 1
	for i in range(n):
		if arr[i] > i + 1:
			print(-1)
			break
	else:
		print(*res)
main()


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
n = int(input())
a = list(mapi())
mp = defaultdict(int)
for i in a:
	mp[i] += 1
q = deque()
a = [0] + a
res = []
j = 0
vis = defaultdict(int)
for i in range(n + 1):
	if mp[i]:
		while mp[i]:
			if len(q) > 0:
				mp[i] -= 1
				tmp = q.popleft()
				res.append(tmp)
				vis[tmp] += 1
			else:
				while mp[j] or vis[j]:
					j += 1
				vis[j] += 1
				res.append(j)
				j += 1
				mp[i] -= 1
		q.append(i)
print(*res)


import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
b = [-1 for k in range(n)]
existe = [False for k in range(100005)]
for k in range(n):
	if a[k] != a[k - 1] and k != 0:
		b[k] = a[k - 1]
		existe[b[k]] = True
existe[a[n - 1]] = 1
m = 0
for k in range(n):
	while existe[m]:
		m += 1
	if b[k] == -1:
		b[k] = m
		existe[m] = True
	print(b[k], end=' ')


import sys
input = sys.stdin.readline
from bisect import bisect_left
n = int(input())
A = list(map(int, input().split()))
SA = set(A)
erase = [i for i in range(2 * 10 ** 5 + 1) if i not in SA]
ei = 0
B = [-1] * n
mex = 0
prev = 0
for (i, v) in enumerate(A):
	if v != prev:
		B[i] = prev
		if prev == erase[ei]:
			ei += 1
	else:
		B[i] = erase[ei]
		ei += 1
	if erase[ei] < v:
		print(-1)
		sys.exit(0)
	prev = v
print(' '.join(map(str, B)))


n = int(input())
a = list(map(int, input().split()))
x = 0
y = 1
t = set(a)
for i in a:
	if i == x:
		while y in t:
			y += 1
		print(y, end=' ')
		y += 1
	else:
		print(x, end=' ')
		x = i


n = int(input())
arr = list(map(int, input().split()))
used = [0 for i in range(10 ** 6 + 1)]
b = [-1 for i in range(n)]
used[arr[0]] = 1
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		used[arr[i]] = 1
		b[i] = arr[i - 1]
m = 0
for i in range(n):
	while used[m] != 0:
		m += 1
	if b[i] == -1:
		b[i] = m
		used[m] = 1
print(*b)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n,) = I()
l = I()
b = [-1] * n
vis = [0] * (n + 1)
k = 0
vis[l[-1]] = 1
for i in range(n - 1, 0, -1):
	if l[i] != l[i - 1]:
		b[i] = l[i - 1]
		vis[l[i - 1]] = 1
for i in range(n):
	if b[i] == -1:
		while vis[k] == 1:
			k += 1
		b[i] = k
		k += 1
print(*b)


N = int(input())
A = list(map(int, input().split()))
mp = {}
for i in range(N):
	mp[A[i]] = i
curr = 0
B = []
for i in range(N):
	if i > 0 and A[i] != A[i - 1]:
		B.append(A[i - 1])
		curr = max(A[i - 1] + 1, curr)
	else:
		while 1 == 1:
			if curr in mp and mp[curr] >= i:
				curr += 1
			else:
				break
		B.append(curr)
		curr += 1
for b in B:
	print(b, end=' ')
print('')


n = int(input())
a = list(map(int, input().split()))
ok = a[0] - 1 <= 0
for i in range(1, n):
	if a[i] - 1 > i:
		ok = False
	if a[i] < a[i - 1]:
		ok = False
if ok == False:
	print(-1)
	quit()
m = set(a)
b = []
s = 0
for i in range(s, n + 10):
	if i not in m:
		b.append(i)
		s = i + 1
		break
for i in range(1, n):
	if a[i] != a[i - 1]:
		b.append(a[i - 1])
		continue
	for j in range(s, n + 10):
		if j not in m:
			b.append(j)
			s = j + 1
			break
for i in range(n):
	print(b[i], end=' ')


import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = list(map(int, input().split()))
ans = [-1] * n
s1 = set(l)
s2 = set()
raj = 0
abc = 0
for i in range(n + 1):
	if i not in s1:
		s2.add(i)
for i in range(1, n):
	if l[i] != l[i - 1]:
		ans[i] = l[i - 1]
bln = sorted(s2)
t = 0
for i in range(n):
	if ans[i] == -1:
		ans[i] = bln[t]
		t += 1
print(*ans)


from sys import stdin as cin
lmap = lambda f, v: list(map(f, v))

def mexarray(a):
	missing = list(sorted(set(range(1, len(a) + 1)) - set(a), reverse=True))
	a = [0] + a
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			yield missing.pop()
		else:
			yield a[i - 1]

def main():
	n = lmap(int, next(cin).strip().split())
	a = lmap(int, next(cin).strip().split())
	print(' '.join(map(str, mexarray(a))))
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
for _ in range(1):
	n = int(input())
	num = list(map(int, input().split()))
	num1 = set(num)
	temp = set()
	for i in range(n + 1):
		if i not in num1:
			temp.add(i)
	num1 = list(temp)
	num1.sort()
	ans = [num1[0]]
	ctr = 1
	for i in range(1, n):
		if num[i] != num[i - 1]:
			ans.append(num[i - 1])
		else:
			ans.append(num1[ctr])
			ctr += 1
	print(*ans)


n = int(input())
a = tuple(map(int, input().split()))
sa = set(a)
san = set()
min_not_in = 0
prev = 0
ans = [0] * n
for i in range(n):
	cur = a[i]
	if cur == prev:
		while min_not_in in sa:
			min_not_in += 1
		ans[i] = min_not_in
		sa.add(min_not_in)
		san.add(min_not_in)
	else:
		ans[i] = prev
		sa.add(prev)
		san.add(prev)
		while prev in san:
			prev += 1
		if cur != prev:
			print(-1)
			break
else:
	print(*ans)


from sys import stdin
from collections import deque
n = int(stdin.readline())
a = list(map(int, stdin.readline().strip().split()))
c = set(a)
d = deque()
for i in range(n + 1):
	if i not in c:
		d.append(i)
b = []
for i in range(n):
	if i != 0:
		if a[i - 1] < a[i]:
			b.append(a[i - 1])
		else:
			b.append(d.popleft())
	else:
		b.append(d.popleft())
print(*b)


n = int(input())
l = [int(j) for j in input().split()]
mx = max(l) + 1
pre = ['#' for i in range(n + 1)]
c = [False for i in range(n + 1)]
for i in range(n - 1):
	if l[i] != l[i + 1]:
		pre[i + 1] = l[i]
		c[l[i]] = True
pre[n] = l[n - 1]
c[l[n - 1]] = True
s = []
for i in range(n + 1):
	if not c[i]:
		s.append(i)
j = 0
for i in range(n):
	if pre[i] == '#':
		pre[i] = s[j]
		j += 1
print(' '.join(map(str, pre[:-1])))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
n = int(input())
a = list(map(int, input().split()))
s = set(a)
ans = []
ele = 0
for i in range(n):
	if i > 0 and a[i] != a[i - 1]:
		ans.append(a[i - 1])
		continue
	while ele in s:
		ele += 1
	ans.append(ele)
	ele += 1
print(*ans)


import os
import heapq
import sys
import bisect
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	n = int(input())
	arr = inar()
	res = [-1] * (n + 1)
	value = [0] * (10 ** 5 + 5)
	arr.insert(0, 0)
	lst = 0
	for i in range(1, n + 1):
		if arr[i] != arr[i - 1]:
			res[i] = arr[i - 1]
			value[arr[i - 1]] = 1
	value[arr[n]] = 1
	m = 0
	for i in range(1, n + 1):
		while value[m]:
			m += 1
		if res[i] == -1:
			res[i] = m
			value[m] = 1
	print(*res[1:n + 1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	test = 1
	for _ in range(test):
		n = int(input())
		ara = [int(num) for num in input().split()]
		mark = [True for _ in range(n + 1)]
		for num in ara:
			mark[num] = False
		take_from = []
		for index in range(n + 1):
			if mark[index]:
				take_from.append(index)
		ans = []
		ans.append(take_from[0])
		take_at = 1
		take_size = len(take_from)
		for index in range(1, n):
			if ara[index] != ara[index - 1]:
				ans.append(ara[index - 1])
			elif take_at < take_size:
				ans.append(take_from[take_at])
				take_at += 1
			else:
				ans.append(n + 1)
		ans = ' '.join(map(str, ans))
		print(ans)
main()


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math as mt
from collections import deque

def main():
	tc = 1
	for _ in range(tc):
		n = ri()
		a = ria()
		b = [0] * n
		vis = [0] * n * 10
		nonvis = []
		f = 0
		for i in range(n):
			vis[a[i]] = 1
			if a[i] > i + 1:
				print(-1)
				f = 1
				break
		if f == 0:
			for i in range(len(vis)):
				if vis[i] != 1:
					nonvis.append(i)
			nonvisd = deque(nonvis)
			print(nonvisd.popleft(), end=' ')
			for i in range(1, n):
				if a[i - 1] != a[i]:
					print(a[i - 1], end=' ')
				else:
					print(nonvisd.popleft(), end=' ')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
use = [False] * (n + 1)
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		use[a[i - 1]] = True
use[a[n - 1]] = True
ind = 0
i = 0
while ind < n:
	if b[ind] == -1:
		while use[i] == True:
			i += 1
		b[ind] = i
		use[i] = True
		ind += 1
	else:
		ind += 1
print(*b)


ll = lambda : list(map(int, input().split()))
s = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
m = 1000000007
n = ii()
a = ll()
m = [0] * 1000001
c = [0] * 1000001
for i in a:
	c[i] += 1
p = 0
q = []
ans = []
for i in range(n + 1):
	if c[i] == 0:
		continue
	while c[i]:
		if q:
			c[i] -= 1
			ans.append(q[0])
			m[q[0]] += 1
			q.pop(0)
		else:
			while c[p] or m[p]:
				p += 1
			m[p] += 1
			ans.append(p)
			p += 1
			c[i] -= 1
	q.append(i)
print(*ans)


n = int(input())
mas = list(map(int, input().split()))
ans = []
have = [0 for i in range(1000009)]
for i in range(n):
	if i > 0 and mas[i - 1] != mas[i]:
		ans.append(mas[i - 1])
		have[mas[i - 1]] = 1
	else:
		ans.append(-1)
j = 0
have[mas[n - 1]] = 1
for i in range(len(ans)):
	if ans[i] == -1:
		while have[j]:
			j += 1
		ans[i] = j
		have[j] = 1
if mas[0] > 1:
	print(-1)
else:
	for x in ans:
		print(x, end=' ')


import sys

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

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
n = iinput()
a = get_list()
s = set(a)
ans = []
ele = 0
for i in range(n):
	if i > 0 and a[i] != a[i - 1]:
		ans.append(a[i - 1])
	else:
		while ele in s:
			ele += 1
		ans.append(ele)
		ele += 1
print(*ans)


from collections import defaultdict
n = int(input())
l = list(map(int, input().split()))
l1 = []
d = defaultdict(int)
for x in l:
	d[x] = 1
ma = 1
if l[0] == 0:
	while d[ma] != 0:
		ma += 1
	d[ma] = 1
	l1.append(ma)
	m = 0
elif l[0] == 1:
	l1.append(0)
	m = 1
	ma = 2
else:
	f = 1
	sys.exit(0)
f = 0
for x in range(1, n):
	if l[x] == m:
		while d[ma] != 0:
			ma += 1
		d[ma] = 1
		l1.append(ma)
	else:
		if l[x] > ma + 1:
			f = 1
			break
		l1.append(m)
		m = l[x]
		ma = max(ma, m)
if f == 1:
	print(-1)
else:
	for x in l1:
		print(x, end=' ')


import math
import heapq, bisect
import sys
from collections import deque
from fractions import Fraction
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree1:

	def __init__(self, data, default=9999999, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	ans = [-1] * n
	r = set(l)
	r1 = set()
	for i in range(n + 1):
		if i not in r:
			r1.add(i)
	for i in range(1, n):
		if l[i] != l[i - 1]:
			ans[i] = l[i - 1]
	mis = sorted(r1)
	t = 0
	for i in range(n):
		if ans[i] == -1:
			ans[i] = mis[t]
			t += 1
	print(*ans, sep=' ')


from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
ans = []
ok = True
s = set(a)
now = 1
p = 0
for i in a:
	if i != p:
		ans.append(p)
		p = i
	else:
		while now in s:
			now += 1
		ans.append(now)
		now += 1
print(*ans)


from collections import Counter
input()
for sjdkla in range(1):
	arr = list(map(int, input().split()))
	count = Counter(arr)
	prev = arr[0]
	impossible = False
	for (ind, i) in enumerate(arr):
		if i > ind + 1:
			impossible = True
		break
	if impossible:
		print(-1)
		continue
	newarr = []
	newset = set()
	safe = 0
	newsafe = None
	while 1:
		if count[safe] == 0:
			break
		safe += 1
	for i in arr:
		if newsafe is not None:
			newarr.append(newsafe)
			newsafe = None
		else:
			newarr.append(safe)
			while 1:
				safe += 1
				if count[safe] == 0:
					break
		count[i] -= 1
		if count[i] == 0:
			newsafe = i
	print(*newarr)


n = int(input())
a = list(map(int, input().split()))
b = []
s = set(a)
(bi1, bi2) = (0, 1)
for i in range(n):
	if a[i] != bi1:
		b.append(bi1)
		if bi2 == a[i]:
			bi2 += 1
	else:
		while bi2 in s:
			bi2 += 1
		b.append(bi2)
		bi2 += 1
	bi1 = a[i]
print(*b)


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
n = int(input())
l = list(map(int, input().split()))
s = [l[0]]
d = dd(int)
d[l[0]] += 1
for i in range(1, n):
	if l[i] != l[i - 1]:
		s.append(l[i])
	d[l[i]] += 1
i = 0
nn = len(s)
res = []
nums = 0
prev = -1
k = 0
while i < n:
	if l[i] != prev and prev != -1:
		res.append(prev)
		prev = l[i]
	else:
		while d[k] != 0:
			k += 1
		res.append(k)
		k += 1
		prev = l[i]
	i += 1
print(*res)


import os
import sys
from io import BytesIO, IOBase
profile = 0
pypy = 1

def iin():
	return int(input())

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

def get_min(a, b):
	(v1, c1) = a
	(v2, c2) = b
	if v1 < v2:
		return b
	elif v1 > v2:
		return a
	elif c1 < c2:
		return a
	else:
		return b

def main():
	t = 1
	while t:
		t -= 1
		n = iin()
		a = lin()
		sa = set(a)
		b = []
		ch1 = 0
		for i in range(n):
			if i > 0 and a[i] != a[i - 1]:
				b.append(a[i - 1])
				continue
			while ch1 in sa:
				ch1 += 1
			b.append(ch1)
			ch1 += 1
		print(*b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if pypy:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
if profile:
	import cProfile
	cProfile.run('main()')
else:
	main()


n = int(input())
a = list(map(int, input().split()))
b = [-1] * (n + 1)
a.append(-1)
f = 0
d = set()
for i in range(1, n + 1):
	if a[i - 1] != a[i]:
		b[i] = a[i - 1]
		d.add(b[i])
d = list(set(list(range(n + 1))) - d)
c = 0
for i in range(n + 1):
	if b[i] == -1:
		b[i] = d[c]
		c += 1
print(*b[:-1])


n = int(input())
a = list(map(int, input().split()))
b = [-1] * n
v = [-1] * (n + 1)
f = 0
v[a[n - 1]] = 1
for i in range(n - 1, 0, -1):
	if a[i] > i + 1:
		f = 1
		break
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
		v[a[i - 1]] = 1
if f == 1:
	print(-1)
vi = []
for i in range(len(v)):
	if v[i] == -1:
		vi.append(i)
j = 0
for i in range(len(b)):
	if b[i] == -1:
		b[i] = vi[j]
		j += 1
print(*b)


import sys, math
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.buffer.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
INF = float('inf')
mod = 998244353
n = int(data())
a = mdata()
s = set(a)
d = dd(int)
for i in range(n):
	d[a[i]] = i
cnt = 0
ans = []
k = 0
for i in range(n):
	while True:
		if cnt in s:
			cnt += 1
		else:
			break
	if k == 0:
		ans.append(cnt)
		if d[a[i]] == i:
			ans.append(a[i])
			k = 1
		cnt += 1
	elif d[a[i]] == i:
		ans.append(a[i])
	else:
		k = 0
if len(ans) > n:
	ans.pop()
print(*ans)


from collections import deque
from sys import stdin, stdout
int_in = lambda : int(stdin.readline())
arr_in = lambda : [int(x) for x in stdin.readline().split()]
mat_in = lambda rows: [arr_in() for y in range(rows)]
str_in = lambda : stdin.readline().strip()
out = lambda o: stdout.write('{}\n'.format(o))
arr_out = lambda o: out(' '.join(map(str, o)))
bool_out = lambda o: out('YES' if o else 'NO')
tests = lambda : range(1, int_in() + 1)
case_out = lambda i, o: out('Case #{}: {}'.format(i, o))

def solve(n, a):
	result = [None] * n
	items_in_a = set(a)
	curr = 0
	for i in range(n):
		if i > 0 and a[i - 1] != a[i]:
			result[i] = a[i - 1]
		else:
			while curr in items_in_a:
				curr += 1
			result[i] = curr
			curr += 1
	return result
n = int_in()
a = arr_in()
arr_out(solve(n, a))


import sys
from sys import setrecursionlimit
setrecursionlimit(10 ** 5)
readline = sys.stdin.readline
n = int(readline())
a = list(map(int, readline().split()))
b = [-1] * n
not_visited = []
visited = [-1] * 10 ** 6
flag = True
for (i, j) in enumerate(a):
	if j > i + 1:
		flag = False
		break
	visited[j] = 1
if not flag:
	print(-1)
	sys.exit(0)
for i in range(1, n):
	if a[i] != a[i - 1]:
		b[i] = a[i - 1]
for (i, j) in enumerate(visited):
	if j == -1:
		not_visited.append(i)
k = 0
for (i, j) in enumerate(b):
	if j == -1:
		b[i] = not_visited[k]
		k += 1
print(*b)


import os
import sys
from io import BytesIO, IOBase
import math

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

def inputArray():
	return input().rstrip().split()

def inputVars():
	return map(int, input().rstrip().split())

def inputNum():
	return int(input())

def main():
	for _ in range(1):
		n = inputNum()
		arr = [0] + inputIntArray()
		ansArr = [-1] * (n + 1)
		usedArrValues = [False] * 10 ** 6
		for pos in range(1, n + 1):
			if arr[pos] != arr[pos - 1]:
				ansArr[pos] = arr[pos - 1]
				usedArrValues[ansArr[pos]] = True
		usedArrValues[arr[-1]] = True
		tempPos = 0
		for pos in range(1, n + 1):
			while usedArrValues[tempPos]:
				tempPos += 1
			if ansArr[pos] == -1:
				ansArr[pos] = tempPos
				usedArrValues[tempPos] = True
			print(ansArr[pos], end=' ')
		print(' ')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys
n = int(sys.stdin.readline())
a = [int(i) for i in sys.stdin.readline().split()]
s = set(a)
bs = [0] * n
at = 0
for i in range(n):
	while at in s:
		at += 1
	bs[i] = at
	at += 1
ans = [0] * n
used = 0
for i in range(n):
	if i != 0 and a[i] != a[i - 1]:
		ans[i] = a[i - 1]
	else:
		ans[i] = bs[used]
		used += 1
print(' '.join([str(i) for i in ans]))


import sys
input = sys.stdin.readline
import math

def inp():
	return int(input())

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

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())

def from_file(f):
	return f.readline

def solve(n, A):
	S = set(A)
	next_num = 0
	memory = A[0]
	b = []
	for (i, ai) in enumerate(A):
		if ai != memory:
			if memory == ai - 1 or next_num >= ai:
				b.append(memory)
				memory = ai
			else:
				return None
		else:
			while next_num in S:
				next_num += 1
			b.append(next_num)
			next_num += 1
	return b
n = inp()
A = inlt()
b = solve(n, A)
if b:
	print(' '.join(map(str, b)))
else:
	print('-1')


n = int(input())
b = [int(i) for i in input().split()]
ans = [-1] * n
visited = [0] * (n + 1)
for i in range(1, n):
	if b[i] != b[i - 1]:
		visited[b[i - 1]] = 1
		ans[i] = b[i - 1]
visited[b[-1]] = 1
count = 0
for i in range(len(ans)):
	if ans[i] == -1:
		while visited[count] == 1:
			count += 1
		ans[i] = count
		visited[count] = 1
print(*ans)


import heapq
t = 1
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	seen = set()
	for i in range(n):
		if arr[i] > 1 + i:
			print(-1)
			t -= 1
			continue
		seen.add(arr[i])
	h = []
	for i in range(n + 1):
		if i not in seen:
			heapq.heappush(h, i)
	ans = []
	for i in range(n):
		if i > 0 and arr[i] != arr[i - 1]:
			heapq.heappush(h, arr[i - 1])
		ans.append(heapq.heappop(h))
	print(' '.join([str(i) for i in ans]))
	t -= 1


n = int(input())
a = list(map(int, input().rstrip().split()))
freq = dict()
for el in a:
	freq[el] = freq.get(el, 0) + 1
pos = list()
for i in range(0, 2 * n + 2):
	if i not in freq:
		pos.append(i)
res = [0 for i in range(n)]
punt = 0
for i in range(n):
	if i == 0 or freq[a[i - 1]] > 0:
		res[i] = str(pos[punt])
		punt += 1
	else:
		res[i] = str(a[i - 1])
	freq[a[i]] -= 1
print(' '.join(res))


n = int(input())
A = list(map(int, input().split()))
S = set(range(n + 1))
S.remove(A[-1])
used = set()
used.add(A[-1])
B = [-1] * n
H = list(range(n + 1))
H = [-x for x in H]
import heapq
heapq.heapify(H)
for i in reversed(range(n)):
	if i != 0:
		if A[i - 1] not in used:
			B[i] = A[i - 1]
			used.add(A[i - 1])
		else:
			while H:
				x = heapq.heappop(H) * -1
				if x not in used:
					break
			B[i] = x
			used.add(x)
	else:
		while H:
			x = heapq.heappop(H) * -1
			if x not in used:
				break
		B[i] = x
		used.add(x)
print(*B)


n = int(input())
l = list(map(int, input().split()))
ni = [0] * (n + 1)
for i in l:
	ni[i] = 1
el = []
for i in range(0, n + 1):
	if ni[i] == 0:
		el.append(i)
a = [el[0]]
ind = 1
for i in range(1, n):
	if l[i] == l[i - 1]:
		a.append(el[ind])
		ind += 1
	else:
		a.append(l[i - 1])
print(*a)


n = int(input())
a = list(map(int, input().split()))
b = []
c = []
d = dict()
for j in range(n):
	if a[j] in d.keys():
		d[a[j]] += 1
	else:
		d[a[j]] = 1
		c.append(a[j])
j = 0
i = 0
while j < len(c):
	p = c[j]
	k = d[c[j]]
	if j != 0:
		b.append(c[j - 1])
		k -= 1
	p = 0
	while p < k:
		if i in d.keys():
			pass
		else:
			b.append(i)
			p += 1
		i += 1
	j += 1
if max(b) > 10 ** 6:
	print(-1)
else:
	print(*b)


import math as ma
n = int(input())
a = list(map(int, input().split()))
e = 0
for i in range(n):
	if a[i] - i - 1 > 0:
		e = 1
		print(-1)
		break
if e == 0:
	b = [-1] * n
	for i in range(n - 1):
		if a[i] != a[i + 1]:
			b[i + 1] = a[i]
	c = set(a)
	d = []
	for i in range(2 * 10 ** 5):
		if i not in c:
			d.append(i)
	j = 0
	for i in range(n):
		if b[i] == -1:
			b[i] = d[j]
			j += 1
	print(*b)


def f(a):
	st = set(a)
	now = 1
	p = 0
	ans = []
	for i in a:
		if i != p:
			ans.append(p)
			p = i
		else:
			while now in st:
				now += 1
			ans.append(now)
			now += 1
	return ans
a = input()
lst = list(map(int, input().strip().split()))
print(*f(lst))


def solution(a):
	b = [-1] * len(a)
	d = {}
	for i in range(1, len(a)):
		if a[i] != a[i - 1]:
			b[i] = a[i - 1]
			d[b[i]] = 1
	d[a[n - 1]] = 1
	m = 0
	for i in range(0, len(a)):
		while d.get(m, 0):
			m = m + 1
		if b[i] == -1:
			b[i] = m
			d[m] = 1
	return b
n = int(input())
a = [int(x) for x in input().split()]
print(*solution(a))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
b = [-1] * (n + 1)
a.append(-1)
f = 0
d = set()
for i in range(1, n + 1):
	if a[i - 1] != a[i]:
		b[i] = a[i - 1]
		d.add(b[i])
d = list(set(list(range(n + 1))) - d)
c = 0
for i in range(n + 1):
	if b[i] == -1:
		b[i] = d[c]
		c += 1
print(*b[:-1])


n = int(input())
arr = [*map(int, input().split())]
s1 = set([*range(n + 1)])
s2 = set(arr)
s1 = s1 - s2
s1 = [*s1][::-1]
s2 = [*s2][::-1]
ans = [s1[-1]]
del s1[-1]
for i in range(1, n):
	if arr[i] != arr[i - 1]:
		ans.append(s2[-1])
		del s2[-1]
	else:
		ans.append(s1[-1])
		del s1[-1]
print(*ans)


from collections import deque
n = int(input())
mark = {}
mark1 = {}
a = list(map(int, input().split()))
t = 0
Ans = []
p = deque()
for i in a:
	mark[i] = 1
for i in a:
	if i == t:
		if len(p) > 0:
			if i == p[0]:
				while mark.get(t, None) != None:
					if mark1.get(t, None) == None:
						p.append(t)
						mark1[t] = 1
					t += 1
				Ans.append(t)
				t += 1
			else:
				q = p.popleft()
				Ans.append(q)
		else:
			while mark.get(t, None) != None:
				if mark1.get(t, None) == None:
					p.append(t)
					mark1[t] = 1
				t += 1
			Ans.append(t)
			t += 1
	elif len(p) > 0:
		if i == p[0]:
			while mark.get(t, None) != None:
				if mark1.get(t, None) == None:
					p.append(t)
					mark1[t] = 1
				t += 1
			Ans.append(t)
			t += 1
		else:
			q = p.popleft()
			Ans.append(q)
	else:
		Ans.append(t)
		t += 1
print(*Ans)


from collections import deque
n = int(input())
s = [int(x) for x in input().split()]
temp = 0
for i in range(0, len(s)):
	if s[i] > i + 1:
		temp = 1
		break
if temp == 1:
	print(-1)
else:
	pos = [0] * (10 * n + 5)
	for i in range(0, len(s)):
		pos[s[i]] = 1
	b = []
	ptr = 0
	kk = 0
	dd = dict()
	for i in range(0, len(s)):
		if ptr == s[i]:
			for j in range(kk, len(pos)):
				if pos[j] == 0:
					b.append(j)
					pos[j] = 1
					dd[j] = 1
					kk = j + 1
					break
		else:
			b.append(ptr)
			dd[ptr] = 1
			pos[ptr] = 1
			for j in range(ptr + 1, len(pos)):
				if dd.get(j) == None:
					ptr = j
					break
	print(*b)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
import heapq as hp
n = int(input())
a = int_array()
mset = {i for i in range(n + 10)}
for i in a:
	if i in mset:
		mset.remove(i)
q = sorted(list(mset))
ans = []
ind = 0
while len(ans) != n:
	x = hp.heappop(q)
	ans.append(x)
	if ind != n - 1:
		if a[ind] != a[ind + 1]:
			hp.heappush(q, a[ind])
	ind += 1
print(*ans)


import sys
input = sys.stdin.readline
from math import ceil, floor, factorial

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(10000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = int_array()
s = set(a)
bs = [0] * n
at = 0
for i in range(n):
	while at in s:
		at += 1
	bs[i] = at
	at += 1
ans = [0] * n
used = 0
for i in range(n):
	if i != 0 and a[i] != a[i - 1]:
		ans[i] = a[i - 1]
	else:
		ans[i] = bs[used]
		used += 1
print(*ans)


def ss(n, l):
	if l != sorted(l) or l[-1] > n:
		return [-1]
	for i in range(n):
		if l[i] > i + 1:
			return [-1]
	v = [0 for _ in range(n + 1)]
	ans = [0 for _ in range(n)]
	j = n
	for i in range(n - 1, 0, -1):
		v[l[i]] = 1
		if l[i - 1] != l[i]:
			ans[i] = l[i - 1]
		else:
			if v[j] == 1:
				while v[j] == 1:
					j -= 1
			ans[i] = j
			j -= 1
	if l[0] == 0:
		while v[j] == 1:
			j -= 1
		ans[0] = j
	return ans
n = int(input())
l = list(map(int, input().split()))
print(*ss(n, l))


from collections import defaultdict

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

def print_list(l):
	print(' '.join(map(str, l)))
MAX = 9999999999
n = int(input())
a = read_list()
b = []
MEX = 0
dic = defaultdict(int)
for t in a:
	dic[t] += 1
m = 0
for i in range(n):
	if a[i] != MEX:
		b.append(MEX)
		MEX = a[i]
		m = max(m, b[-1] + 1)
	else:
		for tmp in range(m, MAX):
			if dic[tmp] == 0:
				b.append(tmp)
				m = tmp + 1
				break
		dic[a[i]] -= 1
print_list(b)


import os, io
from sys import stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
v1 = [False] * (n + 1)
s1 = sorted(list(set(a)), reverse=True)
for i in s1:
	v1[i] = True
tmp = 0
b = [0] * n
flag = True
for i in range(n):
	if len(s1) > 0 and a[i] > s1[-1]:
		b[i] = s1[-1]
		s1.pop()
	elif flag == True:
		if tmp == a[i] or v1[tmp] == True:
			while True:
				tmp += 1
				if tmp > n:
					flag = False
					b[i] = n + 5
					break
				if v1[tmp] == False:
					b[i] = tmp
					tmp += 1
					break
		else:
			b[i] = tmp
			tmp += 1
	else:
		b[i] = n + 5
print(*b)


from collections import deque
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
n = int(input())
a = list(map(int, input().split()))
c = set(a)
d = deque()
for i in range(n + 1):
	if i not in c:
		d.append(i)
b = []
for i in range(n):
	if i != 0:
		if a[i - 1] < a[i]:
			b.append(a[i - 1])
		else:
			b.append(d.popleft())
	else:
		b.append(d.popleft())
print(*b)


import sys

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

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	n = int(ii())
	data = idata()
	slov = dict()
	for i in range(0, n + n + 12):
		slov[i] = 0
	for i in range(n):
		if data[i] > i + 1:
			print(-1)
			return
		slov[data[i]] = 1
	ans = []
	data += [n + n + 12]
	m = 0
	for i in range(n):
		if data[i] > data[i - 1] and i != 0:
			ans += [data[i - 1]]
		else:
			while slov[m]:
				m += 1
			ans += [m]
			slov[m] = 1
	print(*ans)
	return
solve_of_problem()


n = int(input())
a = list(map(int, input().strip().split()))
available_numbers = set(range(2 * n))
removed = set()
for v in a:
	if v not in removed:
		available_numbers.remove(v)
		removed.add(v)
available_numbers = sorted(list(available_numbers))
mex = [-1] * n
for (i, v) in enumerate(a[1:]):
	if a[i] != v:
		mex[i + 1] = a[i]
j = 0
for (k, v) in enumerate(mex):
	if v == -1:
		mex[k] = available_numbers[j]
		j += 1
print(' '.join(map(str, mex)))


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7
from math import ceil
n = int(input())
a = list(map(int, input().split()))
s = set()
for i in range(a[-1] + 5):
	s.add(i)
for i in a:
	if i in s:
		s.remove(i)
ck = [i for i in s]
b = [ck[0]]
j = 1
for i in range(1, n):
	if a[i - 1] == a[i]:
		if j < len(ck):
			b.append(ck[j])
			j += 1
		else:
			b.append(b[-1])
	else:
		b.append(a[i - 1])
print(*b)


def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	index = n - 1
	unique = set()
	while index >= 0:
		if arr[index] > index + 1:
			print(-1)
			return
		unique.add(arr[index])
		index -= 1
	ans = []
	if arr[0] == 1:
		ans.append(0)
		unique.add(0)
	else:
		current = 0
		while current in unique:
			current += 1
		ans.append(current)
		unique.add(current)
	queue = [i for i in range(n + 1) if i not in unique]
	prev = arr[0]
	l = 1
	while l < n:
		if arr[l] != prev and arr[l - 1] in unique:
			unique.remove(arr[l - 1])
			lowest = arr[l - 1]
		else:
			lowest = queue.pop(0)
		ans.append(lowest)
		unique.add(lowest)
		prev = arr[l]
		l += 1
	print(*ans)
solve()


n = int(input())
a = list(map(int, input().split()))
b = [False] * 200000
ans = []
for i in a:
	b[i] = True
for i in range(200000):
	if not b[i]:
		ans.append(i)
print(ans[0], end=' ')
t = 1
for i in range(1, n):
	if a[i] != a[i - 1]:
		print(a[i - 1], end=' ')
	else:
		print(ans[t], end=' ')
		t += 1


def check_if_possible(values):
	for i in range(len(values)):
		if values[i] - 1 > i:
			return False
	return True

def getNextAvailable(arr, ctr):
	for i in range(ctr, len(arr)):
		if arr[i] == 1:
			arr[i] = 0
			return (i, i + 1)
n = int(input())
values = list(map(int, input().strip().split(' ')))
if check_if_possible(values):
	ansarr = [None for i in range(len(values))]
	available_values = [1 for i in range(len(values) + 1)]
	for i in values:
		available_values[i] = 0
	for i in range(1, len(values)):
		if values[i] != values[i - 1]:
			ansarr[i] = values[i - 1]
	mkr = 0
	for i in range(len(ansarr)):
		if ansarr[i] == None:
			(ansarr[i], mkr) = getNextAvailable(available_values, mkr)
	for i in ansarr:
		print(i, end=' ')


n = int(input())
a = [int(x) for x in input().split()]
b = [None] * n
unused = set()
banned = set(a)
mex = 0
c = 0
for i in range(n):
	if a[i] == mex:
		while c in banned:
			c += 1
		b[i] = c
		c += 1
	else:
		if i > 0:
			banned.discard(a[i - 1])
		b[i] = mex
		if c == mex:
			c += 1
		mex = a[i]
print(*b)


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	bb = [0] * n
	ap = 0
	bv = 0
	mex = 0
	ap = 0
	bv = 0
	for i in range(n):
		if i > 0 and aa[i] != aa[i - 1]:
			bb[i] = aa[i - 1]
			if aa[i] > max(bv, bb[i] + 1):
				print(-1)
				return
			bv = max(bb[i] + 1, bv)
		else:
			while ap < n and bv >= aa[ap]:
				if bv == aa[ap]:
					bv += 1
				ap += 1
			bb[i] = bv
			bv += 1
			if aa[i] > bv + 1:
				print(-1)
				return
	print(' '.join(map(str, bb)))
main()


n = int(input())
l = list(map(int, input().split()))
x = 1
prev = 0
s = set(l)
res = []
flag = True
for i in range(n):
	if i + 1 < l[i] or (i > 1 and l[i] < l[i - 1]):
		flag = False
		break
if flag:
	for i in l:
		if i != prev:
			res.append(prev)
			prev = i
		else:
			while x in s:
				x += 1
			res.append(x)
			x += 1
	print(*res)
else:
	print(-1)


n = int(input())
l = list(map(int, input().split()))
if max(l) > n:
	print(-1)
else:
	a = []
	ans = []
	for i in range(n + 1):
		a.append(-1)
		ans.append(-1)
	for i in range(n):
		a[l[i]] = i + 1
	for i in range(n + 1):
		if a[i] != -1:
			ans[a[i]] = i
	print()
	j = 0
	for i in range(n + 1):
		if ans[i] != -1:
			continue
		while a[j] != -1:
			j += 1
		ans[i] = j
		j += 1
	for i in range(n):
		print(ans[i], end=' ')


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(' '.join(list(map(str, a))))

def solve():
	n = I()
	a = L()
	ans = [-1] * n
	b = [0] * (n + 1)
	if a[0] == 1:
		ans[0] = 0
		b[0] = -1
	for i in range(1, n):
		if a[i] > a[i - 1]:
			ans[i] = a[i - 1]
			b[a[i - 1]] = -1
	j = 0
	b[a[-1]] = -1
	for i in range(n):
		if ans[i] == -1:
			while b[j] == -1:
				j += 1
			ans[i] = j
			j += 1
	print(*ans)
for i in range(1):
	solve()


n = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(2 * n + 1)]
for i in range(n):
	B[A[i]] = 1
C = []
for i in range(len(B)):
	if B[i] == 0:
		C.append(i)
ans = [C[0]]
j = 1
mv = C[0]
flag = 0
for i in range(1, n):
	if A[i] == A[i - 1]:
		ans.append(C[j])
		j = j + 1
	else:
		ans.append(A[i - 1])
print(*ans)


import sys
readline = sys.stdin.readline
from collections import deque

def solve():
	N = int(readline())
	A = list(map(int, readline().split()))
	nonused = set(range(N + 1)) - set(A)
	q = deque(sorted(nonused))
	m = 0
	ans = [0] * N
	for i in range(N):
		if A[i] == m:
			ans[i] = q.popleft()
		else:
			ans[i] = m
			if q and q[0] == m:
				q.popleft()
			m = A[i]
	print(*ans)
solve()


import sys
from heapq import heappush, heappop, heapify
from collections import defaultdict

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
N = INT()
A = LIST()
MAX = 10 ** 6
ok = [0] * (MAX + 1)
for (i, a) in enumerate(A):
	ok[a] = i + 1
adjli = defaultdict(list)
for (a, i) in enumerate(ok):
	adjli[i].append(a)
que = []
ans = [0] * N
for i in range(N):
	for a in adjli[i]:
		heappush(que, a)
	if not que:
		print(-1)
		exit()
	ans[i] = heappop(que)
print(*ans)