Initially Ildar has an empty array. He performs $n$ steps. On each step he takes a subset of integers already added to the array and appends the mex of this subset to the array. 

The mex of an multiset of integers is the smallest non-negative integer not presented in the multiset. For example, the mex of the multiset $[0, 2, 3]$ is $1$, while the mex of the multiset $[1, 2, 1]$ is $0$.

More formally, on the step $m$, when Ildar already has an array $a_1, a_2, \ldots, a_{m-1}$, he chooses some subset of indices $1 \leq i_1 < i_2 < \ldots < i_k < m$ (possibly, empty), where $0 \leq k < m$, and appends the $mex(a_{i_1}, a_{i_2}, \ldots a_{i_k})$ to the end of the array.

After performing all the steps Ildar thinks that he might have made a mistake somewhere. He asks you to determine for a given array $a_1, a_2, \ldots, a_n$ the minimum step $t$ such that he has definitely made a mistake on at least one of the steps $1, 2, \ldots, t$, or determine that he could have obtained this array without mistakes.


-----Input-----

The first line contains a single integer $n$ ($1 \leq n \leq 100\,000$) — the number of steps Ildar made.

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($0 \leq a_i \leq 10^9$) — the array Ildar obtained.


-----Output-----

If Ildar could have chosen the subsets on each step in such a way that the resulting array is $a_1, a_2, \ldots, a_n$, print $-1$.

Otherwise print a single integer $t$ — the smallest index of a step such that a mistake was made on at least one step among steps $1, 2, \ldots, t$.


-----Examples-----
Input
4
0 1 2 1

Output
-1
Input
3
1 0 1

Output
1
Input
4
0 1 2 239

Output
4


-----Note-----

In the first example it is possible that Ildar made no mistakes. Here is the process he could have followed.  $1$-st step. The initial array is empty. He can choose an empty subset and obtain $0$, because the mex of an empty set is $0$. Appending this value to the end he gets the array $[0]$.  $2$-nd step. The current array is $[0]$. He can choose a subset $[0]$ and obtain an integer $1$, because $mex(0) = 1$. Appending this value to the end he gets the array $[0,1]$.  $3$-rd step. The current array is $[0,1]$. He can choose a subset $[0,1]$ and obtain an integer $2$, because $mex(0,1) = 2$. Appending this value to the end he gets the array $[0,1,2]$.  $4$-th step. The current array is $[0,1,2]$. He can choose a subset $[0]$ and obtain an integer $1$, because $mex(0) = 1$. Appending this value to the end he gets the array $[0,1,2,1]$. 

Thus, he can get the array without mistakes, so the answer is $-1$.

In the second example he has definitely made a mistake on the very first step, because he could not have obtained anything different from $0$.

In the third example he could have obtained $[0, 1, 2]$ without mistakes, but $239$ is definitely wrong.

Difficulty: EASY

Solutions:
n = int(input())
a = list(map(int, input().split()))
m = -1
for i in range(n):
	if a[i] > m + 1:
		exit(print(i + 1))
	else:
		m = max(a[i], m)
print(-1)


def main():
	n = int(input())
	arr = [int(x) for x in input().strip().split()]
	s = set([-1])
	for i in range(n):
		if arr[i] - 1 not in s:
			print(i + 1)
			return
		s.add(arr[i])
	print(-1)
main()


n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
	print(1)
else:
	out = -1
	mx = 0
	for i in range(1, n):
		if mx + 1 < a[i]:
			out = i + 1
			break
		elif mx + 1 == a[i]:
			mx = a[i]
	print(out)


n = int(input())
a = [int(x) for x in input().split()]
tr = False
c = 0
mval = -1
for i in range(n):
	if a[i] > mval + 1:
		print(i + 1)
		tr = True
		break
	mval = max(mval, a[i])
if tr == False:
	print(-1)


a = int(input())
b = list(map(int, input().split()))
max = 0
c = [0]
m = c[0]
if b[0] != 0:
	print(1)
	exit()
else:
	for i in range(1, len(b)):
		if b[i - 1] > max:
			max = b[i - 1]
		if b[i] > max + 1:
			print(i + 1)
			exit()
print(-1)


def solve():
	if a[0] != 0:
		return 1
	r = 0
	for i in range(n):
		if a[i] != 0 and a[i] > r + 1:
			return i + 1
		else:
			r = max(r, a[i])
	return -1
n = int(input())
a = list(map(int, input().split()))
print(solve())


n = int(input())
a = list(map(int, input().split()))
maxx = 0
flag = 0
for i in range(n):
	if i == 0:
		if a[i] != 0:
			print(i + 1)
			flag = 1
			break
	elif a[i] > maxx + 1:
		print(i + 1)
		flag = 1
		break
	elif a[i] == maxx + 1:
		maxx = a[i]
if flag == 0:
	print(-1)


n = int(input())
arr = [int(i) for i in input().split()]
max = ans = -1
for i in range(n):
	tmp = arr[i]
	if tmp > max + 1:
		ans = i + 1
		break
	if tmp > max:
		max = tmp
print(ans)


from sys import stdin
import sys
n = int(stdin.readline().strip())
s = tuple(map(int, stdin.readline().strip().split()))
if s[0] != 0:
	print(1)
	return
x = 1
ans = -1
for i in range(1, n):
	if s[i] <= x:
		x = max(x, s[i] + 1)
	else:
		ans = i + 1
		break
print(ans)


n = int(input())
s = 0
for (i, x) in enumerate(map(int, input().split()), 1):
	if x > s:
		print(i)
		exit()
	s += x == s
print(-1)


num = int(input())
arr = list(map(int, input().split()))
mx = 0
for (i, val) in enumerate(arr):
	if val > mx + 1:
		print(i + 1)
		exit()
	mx = max(val, mx)
	if mx > i:
		print(i + 1)
		exit()
print(-1)


def read():
	return [int(v) for v in input().split()]

def main():
	n = read()[0]
	a = read()
	biggest_possible = 0
	for i in range(n):
		if a[i] > biggest_possible:
			print(i + 1)
			return
		if a[i] == biggest_possible:
			biggest_possible += 1
	print(-1)
main()


n = int(input())
l = list(map(int, input().split()))
k = -1
m = -1
for i in range(n):
	if l[i] - m > 1:
		k = i + 1
		break
	else:
		m = max(m, l[i])
print(k)


n = int(input())
arr = [int(i) for i in input().split()]
max_ = 0
if arr[0] != 0:
	print(1)
	exit()
for i in range(1, n):
	if arr[i] > arr[i - 1]:
		if arr[i] - max_ >= 2:
			print(i + 1)
			exit()
		else:
			max_ = max(arr[i], max_)
print(-1)


n = int(input())
a = [int(i) for i in input().split()]
e = 0
flag = 0
for i in range(0, len(a)):
	if a[i] == e:
		e = e + 1
	elif a[i] < e:
		pass
	else:
		flag = i + 1
		break
if flag == 0:
	print(-1)
else:
	print(flag)


def mex(a, n):
	m = -1
	for i in range(n):
		if a[i] - m > 1:
			return i + 1
		m = max(m, a[i])
	return -1
n = int(input())
a = [*map(int, input().split())]
print(mex(a, n))


num = int(input())
str1 = [int(x) for x in input().split()]
count = []
temp = 0
for i in range(0, len(str1)):
	if str1[i] == temp:
		temp = str1[i] + 1
	if str1[i] <= temp:
		continue
	else:
		count.append(i + 1)
if len(count) == 0:
	print('-1')
else:
	print(min(count))


n = int(input())
A = list(map(int, input().split()))
q = -2
kek = {ww - 1: 0 for ww in set(A)}
for elemq in range(n):
	elem = A[elemq]
	kek[elem] = 1
	if not kek[elem - 1] and elem != 0:
		q = elemq
		break
print(q + 1)


from sys import stdin, stdout

def ans(mx, l):
	for i in range(len(l)):
		if l[i] > mx + 1:
			return i + 1
		mx = max(mx, l[i])
	return -1
n = int(stdin.readline())
l = list(map(int, stdin.readline().split()))
stdout.write('%d' % ans(-1, l))


stat = 0
num = int(input())
arr = list(map(int, input().split(' ')))
m = 0
for i in range(num):
	if arr[i] > min(m + 1, i):
		print(i + 1)
		stat += 1
		break
	elif arr[i] > m:
		m = arr[i]
if stat == 0:
	print(-1)


from collections import defaultdict
n = int(input())
arr = list(map(int, input().split()))
present = defaultdict()
ans = -1
moves = 1
flag = True
if arr[0] != 0:
	print(1)
else:
	present[0] = 1
	for i in range(1, len(arr)):
		moves += 1
		if arr[i] - 1 not in present and arr[i] != 0:
			flag = False
			break
		else:
			present[arr[i]] = 1
	if flag:
		print(-1)
	else:
		print(moves)


import sys
a = list(map(int, sys.stdin.readlines()[1][:-1].split()))
mx = 0
for i in range(len(a)):
	if a[i] > mx:
		print(i + 1)
		sys.exit(0)
	mx = max(mx, a[i] + 1)
print(-1)


n = int(input())
arr = map(int, input().split())
available = 0
i = 0
correct = True
for x in arr:
	if x > available:
		correct = False
		break
	available = max(available, x + 1)
	i += 1
print(-1 if correct else i + 1)


n = int(input())
l = [-1] + list(map(int, input().split()))
if l[1] != 0:
	print(1)
else:
	mx = 0
	for i in range(2, n + 1):
		if l[i] > mx + 1:
			print(i)
			exit(0)
		mx = max(l[i], mx)
	print(-1)


R = lambda : list(map(int, input().split()))
n = int(input())
a = R()
k = False
mx = -1
for i in range(n):
	if mx + 1 < a[i]:
		k = True
		break
	if mx < a[i]:
		mx = a[i]
print(i + 1 if k else -1)


n = int(input())
a = [int(x) for x in input().split()]
i = 0
m = -1
while i < n:
	if a[i] > m + 1:
		print(i + 1)
		exit(0)
	m = max(m, a[i])
	i += 1
print(-1)


n = int(input())
a = list(map(int, input().split()))
maxi = -1
ans = -1
for x in range(n):
	if a[x] > maxi + 1:
		ans = x + 1
		break
	maxi = max(a[x], maxi)
print(ans)


n = int(input())
a = list(map(int, input().split()))
k = 0
s = 0
for i in range(n):
	if a[i] > k:
		s = i + 1
		break
	k = max(k, a[i] + 1)
if s > 0:
	print(s)
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
s = set()
s.add(-1)
for i in range(n):
	if not s.__contains__(a[i] - 1):
		print(i + 1)
		exit()
	s.add(a[i])
print(-1)


n = int(input())
l = input().split()
if l[0] != '0':
	print(1)
	exit()
m = 0
for i in range(1, n):
	if int(l[i]) > m + 1:
		print(i + 1)
		exit()
	if int(l[i]) >= m + 1:
		m = int(l[i])
print(-1)


n = int(input())
a = map(int, input().split(' '))
max = 0
wrong_step = -1
for (i, e) in enumerate(a):
	if e > max:
		wrong_step = i + 1
		break
	if e == max:
		max += 1
print(wrong_step)


n = int(input())
mas = list(map(int, input().split()))
m = -1
for (i, el) in enumerate(mas):
	if el > m + 1:
		print(i + 1)
		exit(0)
	if el > m:
		m = el
print('-1')


n = input()
A = list(map(int, input().split(' ')))
max_seen = -1
for (ix, a) in enumerate(A):
	if a > max_seen + 1:
		print(ix + 1)
		return
	max_seen = max(max_seen, a)
print(-1)


s = int(input())
i = 1
z = -1
for i0 in input().split():
	if int(i0) > z + 1:
		print(i)
		return
	else:
		z = max(z, int(i0))
	i = i + 1
print(-1)


n = int(input())
a = list(map(int, input().split()))
m = 0
z = True
if a[0] != 0:
	print(1)
else:
	for i in range(n):
		if a[i] > m + 1:
			print(i + 1)
			z = False
			break
		m = max(m, a[i])
	if z == True:
		print(-1)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left
printHeap = str()
test = False
memory_constrained = False

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def test_print(output):
	if test:
		stdout.write(str(output) + '\n')

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

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

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def main():
	n = get_int()
	li = get_list()
	max = li[0]
	if max != 0:
		print(1)
		return
	j = 1
	for i in li:
		if i <= max:
			j += 1
			continue
		elif i == max + 1:
			max = i
		else:
			print(j)
			return
		j += 1
	print(-1)
cProfile.run('main()') if test else main()


n = int(input())
a = list(map(int, input().split()))
mx = -1
for (step, elem) in enumerate(a):
	if elem > mx + 1:
		print(step + 1)
		exit(0)
	else:
		mx = max(mx, elem)
print(-1)


n = int(input())
a = list(map(int, input().split()))
ans = -1
checked = {-1}
for i in range(n):
	if a[i] in checked:
		continue
	elif a[i] - 1 in checked:
		checked.add(a[i])
		continue
	ans = i + 1
	break
print(ans)


input()
a = list(map(int, input().split()))
b = {-1: True}
(ans, i) = (-1, 1)
for x in a:
	b[x] = True
	c = b.get(x - 1, False)
	if not c:
		ans = i
		break
	i += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
t = -1
f = True
for i in range(n):
	if a[i] > t + 1:
		print(i + 1)
		f = False
		break
	t = max(t, a[i])
if f:
	print(-1)


import collections

def main():
	n = int(input())
	num = list(map(int, input().split()))
	(prevMax, totMax) = (-1, float('-inf'))
	for (i, v) in enumerate(num):
		totMax = max(totMax, v)
		if totMax - prevMax in [0, 1]:
			prevMax = totMax
		else:
			print(i + 1)
			return
	print(-1)
main()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1 and a[0] == 0:
		return -1
	if n == 1 and a[0] != 0:
		return 1
	if a[0] == 0 and a[1] > 1:
		return 2
	if a[0] != 0 or a[1] > 1:
		return 1
	used = set()
	used.add(a[0])
	used.add(a[1])
	ans = 0
	mx = max(a[0], a[1])
	for i in range(2, n):
		if a[i] not in used and abs(a[i] - mx) > 1:
			ans = i + 1
			break
		else:
			used.add(a[i])
			mx = max(mx, a[i])
	if ans == 0:
		return -1
	return ans
print(main())


import sys, math
data = sys.stdin.readlines()
n = int(data[0])
data = list(map(int, data[1].strip().split()))
max_n = 0
if data[0] != 0:
	print(1)
else:
	for t in range(1, n):
		if data[t] > max_n + 1:
			print(t + 1)
			break
		elif data[t] == max_n + 1:
			max_n = data[t]
	else:
		print(-1)


n = int(input())
l = input().split()
l = list(map(int, l))
c = 0
flag = True
for i in range(len(l)):
	if l[i] > c:
		print(i + 1)
		flag = False
		break
	elif l[i] < c:
		pass
	else:
		c = c + 1
if flag:
	print(-1)


import sys
n = int(input())
l = list(map(int, input().split()))
pos_max = 0
for i in range(len(l)):
	if l[i] > pos_max:
		print(i + 1)
		return
	elif l[i] == pos_max:
		pos_max += 1
print('-1')


n = int(input())
a = [int(t) for t in input().split(' ')]
maxn = 0
for i in range(len(a)):
	if a[i] <= maxn:
		maxn = max(maxn, a[i] + 1)
	else:
		print(i + 1)
		break
else:
	print(-1)


def good(n, a):
	m = 0
	if a[0] != 0:
		return 1
	for i in range(n):
		if a[i] - m > 1:
			return i + 1
		if a[i] > m:
			m = a[i]
	return -1
n = int(input())
a = list(map(int, input().split()))
print(good(n, a))


n = int(input())
tab = list(map(int, input().split()))
S = set()
for i in range(n):
	if tab[i] in S or tab[i] - 1 in S or (i == 0 and tab[i] == 0):
		S.add(tab[i])
	else:
		print(i + 1)
		exit()
print(-1)


n = int(input())
l = list(map(int, input().split()))
d = {-1}
for i in range(n):
	if l[i] - 1 in d:
		d.add(l[i])
		pass
	else:
		print(i + 1)
		exit()
print(-1)


from math import *
n = int(input())
A = list(map(int, input().split()))
ans = -1
maxs = 0
for j in range(n):
	if A[j] > maxs:
		ans = j + 1
		break
	else:
		maxs = max(maxs, A[j] + 1)
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
if arr[0] != 0:
	print(1)
	exit()
elif n == 1:
	print(-1)
	exit()
elif n > 1 and arr[1] > 1:
	print(2)
	exit()
else:
	i = 2
	maxx = arr[1]
	while i < n:
		if arr[i] > maxx + 1:
			print(i + 1)
			exit()
		if arr[i] > maxx:
			maxx = arr[i]
		i += 1
print(-1)


n = int(input())
l = list(map(int, input().split()))
m = {-1: True}
k = 1
for i in l:
	m[i] = True
	if m.get(i - 1, -2) == -2:
		print(k)
		break
	k += 1
else:
	print(-1)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
lens = read_int()
arrs = read_ints()
ans = -1
should_be = -1
for (i, v) in enumerate(arrs):
	if v > should_be + 1:
		ans = i + 1
		break
	should_be = max(v, should_be)
print(ans)


n = int(input())
l = [int(i) for i in input().split()]
if l[0] != 0:
	print(1)
	exit()
mini = l[0]
f = 0
maxi = max(-1, l[0])
for i in range(1, n):
	if l[i] <= maxi + 1:
		maxi = max(maxi, l[i])
	else:
		print(i + 1)
		f = 1
		break
if f == 0:
	print(-1)


R = lambda : map(int, input().split())
n = int(input())
arr = R()
small = large = 0
for (i, a) in enumerate(arr):
	if small <= a <= large:
		if a == large:
			large += 1
	else:
		ans = i + 1
		break
else:
	ans = -1
print(ans)


n = int(input())
a = list(map(int, input().split()))
(current_max, ans) = (-1, -1)
for i in range(n):
	if a[i] == current_max + 1:
		current_max = a[i]
	elif a[i] > current_max + 1:
		ans = i + 1
		break
print(ans)


n = int(input())
a = list(map(int, input().split()))
output = -1
max_ = a[0]
for j in range(n):
	if j == 0 and a[j] != 0:
		output = 1
		break
	elif j > 0 and a[j] - max_ > 1:
		output = j + 1
		break
	if a[j] > max_:
		max_ = a[j]
print(output)


n = int(input())
lst = [int(x) for x in input().split()]
if lst[0] != 0:
	print(1)
	exit()
maxi = 0
for i in range(n - 1):
	if maxi >= lst[i + 1] or maxi + 1 == lst[i + 1]:
		if lst[i + 1] > maxi:
			maxi = lst[i + 1]
		continue
	else:
		print(i + 2)
		exit()
print(-1)


input()
m = -1
for (i, a) in enumerate(map(int, input().split())):
	if a > m + 1:
		print(i + 1)
		break
	else:
		m = max(m, a)
else:
	print(-1)


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


import sys
n = int(input())
a = list(map(int, input().split()))
max_so_far = -1
for i in range(n):
	if a[i] > max_so_far + 1:
		print(i + 1)
		break
	else:
		max_so_far = max(max_so_far, a[i])
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
f = 0
r = True
if a[0] != 0:
	print(1)
	r = False
else:
	for i in range(1, n):
		if a[i] - f > 1:
			print(i + 1)
			r = False
			break
		else:
			f = max(f, a[i])
if r:
	print(-1)


n = int(input())
v = [int(x) for x in input().split()]
Max = -1
for i in range(len(v)):
	if v[i] > Max + 1:
		print(i + 1)
		break
	else:
		Max = max(v[i], Max)
else:
	print(-1)


n = int(input())
arr = list(map(int, input().split()))
ans = -1
pointer = -1
for i in range(n):
	if pointer + 1 == arr[i]:
		pointer += 1
	elif pointer + 1 < arr[i]:
		ans = i + 1
		break
print(ans)


n = int(input())
a = list(map(int, input().split()))
s = 0
for (j, i) in enumerate(a):
	if i > s:
		print(j + 1)
		return
	if i == s:
		s += 1
print(-1)


samu = -1
s = int(input())
a = [int(x) for x in input().split()]
for i in range(s):
	if a[i] <= samu:
		continue
	if a[i] == samu + 1:
		samu += 1
	else:
		print(i + 1)
		break
else:
	print('-1')


n = int(input())
a = [int(i) for i in input().split()]
ret = -1
mx = -1
for i in range(n):
	cur = a[i]
	if cur <= mx + 1:
		if cur > mx:
			mx = cur
	else:
		ret = i + 1
		break
print(ret)


n = int(input())
l = list(map(int, input().split()))
d = -1
k = -1
for i in range(len(l)):
	if l[i] > d + 1:
		k = i + 1
		break
	d = max(d, l[i])
print(k)


n = map(int, input().split())
l = list(map(int, input().split()))
ma = 0
l1 = [0]
for (i, j) in enumerate(l):
	if j > min(i, ma + 1):
		exit(print(i + 1))
	ma = max(j, ma)
print('-1')


n = int(input())
a = list(map(int, input().split()))
err = False
if a[0] != 0:
	print(1)
else:
	max = 0
	for i in range(n):
		if a[i] > max + 1:
			print(i + 1)
			err = True
			break
		if a[i] > max:
			max = a[i]
	if not err:
		print(-1)


steps = int(input())
intA = list(map(int, input().split()))
res = -1
posX = set([0])
for i in range(len(intA)):
	if intA[i] not in posX:
		res = i + 1
		break
	else:
		posX.add(intA[i] + 1)
print(res)


n = int(input())
a = list(map(int, input().split()))
maxx = -1
minn = -1
for i in range(n):
	if a[i] == maxx + 1:
		maxx = a[i]
	elif a[i] > maxx + 1:
		minn = i
		break
if minn == -1:
	print(minn)
else:
	print(minn + 1)


import sys
n = int(input())
a = list(map(int, input().split()))
a_max = -1
for i in range(n):
	if a[i] > a_max + 1:
		print(i + 1)
		sys.exit()
	a_max = max(a_max, a[i])
print(-1)


def main():
	n = int(input())
	array = [int(c) for c in input().split()]
	rng = 0
	for (i, e) in enumerate(array):
		if e > rng:
			print(i + 1)
			return 0
		if e + 1 > rng:
			rng = e + 1
	print(-1)
	return 0
main()


n = int(input())
la = list(map(int, input().rstrip().split()))
i = 0
p = []
c = 0
for x in range(n):
	if la[x] < i:
		i -= 1
	elif la[x] == i:
		pass
	else:
		index = x + 1
		c = 1
		break
	i += 1
if c == 1:
	print(index)
else:
	print('-1')


n = int(input())
array = [int(x) for x in input().split()]
d = {0}
m = -1
for (i, x) in enumerate(array):
	if x not in d and x != m + 1:
		print(i + 1)
		break
	else:
		d.add(x)
		if x == m + 1:
			m += 1
else:
	print(-1)


s = int(input())
i = 1
z = -1
ans = -1
for i0 in input().split():
	if int(i0) > z + 1:
		ans = i
		break
	else:
		z = max(z, int(i0))
	i = i + 1
print(ans)


n = int(input())
a = list(map(int, input().strip().split()))
(k, ans) = (-1, -1)
for i in range(n):
	if a[i] > k + 1:
		ans = i + 1
		break
	k = max(a[i], k)
print(ans)


n = int(input())
a = [int(x) for x in input().split()]
if a[0] != 0:
	print(1)
else:
	max = 0
	flag = 1
	for i in range(1, n):
		if a[i] > max + 1:
			print(i + 1)
			flag = 0
			break
		elif a[i] == max + 1:
			max = max + 1
	if flag == 1:
		print(-1)


import sys
n = int(input())
c = list(map(int, input().split()))
mx = -1
for i in range(n):
	if c[i] > mx + 1:
		print(i + 1)
		sys.exit()
	mx = max(mx, c[i])
print(-1)


input()
a = tuple(map(int, input().split()))
top = -1
for (i, x) in enumerate(a, start=1):
	if x - top <= 1:
		top = max(x, top)
	else:
		print(i)
		return
print(-1)


n = int(input())
a = [int(i) for i in input().split()]
possi = True
ind = -1
if a[0] != 0:
	possi = False
	ind = 1
else:
	curr_max = 0
	for i in range(1, len(a)):
		if a[i] - 1 > curr_max:
			possi = False
			ind = i + 1
			break
		curr_max = max(a[i], curr_max)
if possi:
	print(-1)
else:
	print(ind)


n = int(input())
a = list(map(int, input().split()))
d = {}
x = set()
flag = 0
if a[0] != 0:
	print(1)
else:
	x.add(0)
	for i in range(1, n):
		if len(x) >= a[i]:
			x.add(a[i])
		else:
			print(i + 1)
			flag = 1
			break
	if flag == 0:
		print(-1)


n = int(input())
ls = list(map(int, input().strip().split(' ')))
count = 0
f = 0
if ls[0] != 0:
	print('1')
else:
	l = 0
	for x in ls:
		count += 1
		if x > l + 1:
			f = 1
			break
		elif x > l:
			l = x
	if f == 1:
		print(count)
	else:
		print('-1')


from sys import stdin, stdout
n = int(stdin.readline().strip())
arr = list(map(int, stdin.readline().split()))
mydict = dict()
mydict[-1] = True
for i in range(n):
	try:
		if mydict[arr[i] - 1] == True:
			mydict[arr[i]] = True
			continue
	except:
		print(i + 1)
		break
else:
	print(-1)


def mex(lst):
	(a, k) = (list(), -1)
	for i in range(len(lst)):
		if lst[i] > k + 1:
			a.append(i + 1)
		k = max(k, lst[i])
	if a:
		return a[0]
	return -1
n = int(input())
b = [int(j) for j in input().split()]
print(mex(b))


n = int(input())
a = [int(x) for x in input().split()]

def check():
	if a[0] != 0:
		print(1)
		return
	mx = 0
	for t in range(1, n):
		if a[t] > mx + 1:
			print(t + 1)
			return
		elif a[t] == mx + 1:
			mx += 1
	print(-1)
check()


import sys
n = int(sys.stdin.readline())
arr = list(map(int, sys.stdin.readline().split()))
if arr[0] != 0:
	print(1)
else:
	now = 0
	for i in range(n):
		if arr[i] <= now + 1:
			if arr[i] > now:
				now = arr[i]
		else:
			print(i + 1)
			sys.exit(0)
	print(-1)


n = int(input())
l = list(map(int, input().split()))
summ = 0
maxx = 0
r = -1
for i in range(n):
	if l[i] > i:
		print(i + 1)
		r = 1
		break
	elif maxx + 1 < l[i]:
		print(i + 1)
		r = 1
		break
	if l[i] > maxx:
		maxx = l[i]
if r != 1:
	print('-1')


def sol():
	rd = lambda : list(map(int, input().split()))
	n = int(input())
	arr = rd()
	if arr[0] != 0:
		return 1
	else:
		mi = arr[0]
		ma = arr[0]
		for i in range(1, len(arr)):
			if not (arr[i] == ma + 1 or (arr[i] >= mi and arr[i] <= ma) or (ma == mi and arr[i] == ma + 1)):
				return i + 1
			ma = max(arr[i], ma)
	return -1
print(sol())


l = int(input())
arr = list(map(int, input().strip().split()))
if arr[0] == 0:
	i = 2
	max = 0
	for a in arr[1:]:
		if a > max + 1:
			print(i)
			break
		if a > max:
			max = a
		i += 1
	if i - 1 == l:
		print(-1)
else:
	print(1)


n = int(input())
arr = list(map(int, input().split()))
mx = -1
for (idx, v) in enumerate(arr):
	if mx + 1 == v:
		mx = v
	elif v > mx + 1:
		print(idx + 1)
		exit(0)
print(-1)


n = int(input())
arr = map(int, input().split())
ans = -1
curmax = -1
for (i, num) in enumerate(arr):
	if num - curmax > 1:
		ans = i + 1
		break
	curmax = max(curmax, num)
print(ans)


n = int(input())
A = list(map(int, input().split()))
m = 0
for (i, a) in enumerate(A):
	if a > m:
		print(i + 1)
		exit()
	m = max(m, a + 1)
print(-1)


import math as ma
import sys
from sys import exit
from decimal import Decimal as dec
from itertools import permutations

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

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
n = nu()
a = li()
fl = True
ind = -1
cc = 0
for i in range(n):
	if a[i] <= cc:
		if a[i] == cc:
			cc += 1
		continue
	ind = i + 1
	break
print(ind)


n = int(input())
arr = list(map(int, input().split()))
mist = 0
if arr[0] == 0:
	mex = 1
	for i in range(1, n):
		if arr[i] > mex and mist == 0:
			mist = 1
			print(i + 1)
		else:
			mex = max(mex, arr[i] + 1)
else:
	print(1)
	mist = 1
if mist == 0:
	print(-1)


n = int(input())
cl = list(map(int, input().split()))
mx = -1
for i in range(n):
	if cl[i] == 0:
		if mx == -1:
			mx = 0
	elif cl[i] > mx:
		if cl[i] != 0:
			if cl[i] - mx != 1:
				print(i + 1)
				exit()
		mx = cl[i]
print(-1)


n = int(input())
a = list(map(int, input().split()))
mex = -1
for i in range(n):
	if a[i] <= mex:
		continue
	elif a[i] == mex + 1:
		mex += 1
	else:
		print(i + 1)
		exit()
print(-1)


n = int(input())
a = [int(e) for e in input().split()]
e = 0
if a[0] != 0:
	print(1)
	exit()
for i in range(n):
	if a[i] > e + 1:
		print(i + 1)
		exit()
	if a[i] == e + 1:
		e = a[i]
print(-1)


n = int(input())
a = [int(i) for i in input().split()]
c = -1
maxx = 0
for i in range(n):
	el = a[i]
	if el > i:
		c = i + 1
		break
	elif i != 0 and el > maxx + 1:
		c = i + 1
		break
	elif el == maxx + 1:
		maxx += 1
	else:
		continue
print(c)


n = int(input())
guys = list(map(int, input().split()))
maxi = -1
done = 0
for i in range(n):
	if guys[i] > maxi + 1 and done == 0:
		print(i + 1)
		done = 1
	else:
		maxi = max(maxi, guys[i])
if done == 0:
	print(-1)


input()
(x, y) = (-1, 0)
for (i, v) in enumerate(map(int, input().split()), 1):
	if v > y:
		x = i
		break
	y = y + (v == y)
print(x)


def main():
	n = int(input())
	m = [int(x) for x in input().split()]
	i = 0
	max_elem = -1
	while i < n:
		delta = m[i] - max_elem
		if delta > 1:
			return i + 1
		if delta == 1:
			max_elem += 1
		i += 1
	return -1
res = main()
print(res)


n = int(input())
a = list(map(int, input().split()))
mx = -1
ind = -1
for i in range(n):
	if a[i] > mx + 1:
		ind = i + 1
		break
	mx = max(mx, a[i])
print(ind)


n = int(input())
arr = list(map(int, input().split()))
step = 0
mx = 0
for i in range(n):
	if arr[0] == 0:
		if arr[i] - mx > 1:
			print(step + 1)
			break
		else:
			step += 1
	else:
		print(1)
		break
	mx = max(arr[i], mx)
if step == n:
	print(-1)


n = int(input())
a = input().split()
for i in range(n):
	a[i] = int(a[i])
if a[0] != 0:
	print(1)
	quit()
mine = 0
for i in range(1, n):
	flag = True
	if a[i] - mine <= 1:
		flag = False
	if a[i] > mine:
		mine = a[i]
	if flag:
		print(i + 1)
		quit()
print(-1)


import sys
nb = int(sys.stdin.readline())
liste = list(map(int, sys.stdin.readline().split()))
last = -1
out = True
for i in range(nb):
	if liste[i] > last + 1:
		print(i + 1)
		out = False
		break
	else:
		last = max(last, liste[i])
if out:
	print(-1)


n = int(input())
from collections import defaultdict
l = [-1] + list(map(int, input().split()))
if n == 1:
	if l[1] != 0:
		print(1)
	else:
		print(-1)
elif l[1] != 0:
	print(1)
else:
	d = defaultdict(int)
	d[0] = 1
	d[-1] = 1
	for i in range(2, n + 1):
		if not d[l[i] - 1]:
			print(i)
			exit(0)
		d[l[i]] = 1
	print(-1)


N = int(input())
A = [int(s) for s in input().split(' ')]
maxl = -1
for (i, x) in enumerate(A):
	if x > maxl + 1 or x < 0:
		print(i + 1)
		exit()
	if x > maxl:
		maxl = x
print(-1)


n = int(input())
l = list(map(int, input().split()))
if l[0] != 0:
	print(1)
else:
	m = l[0]
	count = 0
	for i in range(1, n):
		if m < l[i - 1]:
			m = l[i - 1]
		if l[i] > m + 1:
			print(i + 1)
			break
	else:
		print(-1)


n = int(input())
a = list(map(int, input().split()))
i = -1
y = True
k = 0
for j in a:
	if j > i + 1:
		y = False
		break
	elif j == i + 1:
		i += 1
	k += 1
if not y:
	print(k + 1)
else:
	print(-1)


N = int(input())
X = list(map(int, input().split()))
if X[0] != 0:
	print(1)
	exit()
MySet = {-1, 0}
for i in range(N):
	if X[i] - 1 not in MySet:
		print(i + 1)
		exit()
	MySet.add(X[i])
print(-1)


def get_input_list():
	return list(map(int, input().split()))
n = int(input())
a = get_input_list()
m = -1
r = -1
i = 0
while i < n:
	if a[i] <= m:
		i += 1
		continue
	elif a[i] == m + 1:
		m = a[i]
		i += 1
	else:
		print(i + 1)
		break
if i == n:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
max_el = -1
er = -1
for i in range(len(a)):
	if a[i] - max_el > 1:
		er = i + 1
		break
	if a[i] > max_el:
		max_el = a[i]
print(er)


import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque, Counter
from math import gcd, sqrt, factorial, ceil, log10, log2, floor
from itertools import permutations
from heapq import heappush, heappop, heapify
inf = float('inf')
mod = 998244353

def factorial_p(n, p):
	ans = 1
	if n <= p // 2:
		for i in range(1, n + 1):
			ans = ans * i % p
	else:
		for i in range(1, p - n):
			ans = ans * i % p
		ans = pow(ans, p - 2, p)
		if n % 2 == 0:
			ans = p - ans
	return ans

def nCr_p(n, r, p):
	ans = 1
	while n != 0 or r != 0:
		(a, b) = (n % p, r % p)
		if a < b:
			return 0
		ans = ans * factorial_p(a, p) * pow(factorial_p(b, p), p - 2, p) * pow(factorial_p(a - b, p), p - 2, p) % p
		n //= p
		r //= p
	return ans

def prime_sieve(n):
	flag = n % 6 == 2
	sieve = bytearray((n // 3 + flag >> 3) + 1)
	for i in range(1, int(n ** 0.5) // 3 + 1):
		if not sieve[i >> 3] >> (i & 7) & 1:
			k = 3 * i + 1 | 1
			for j in range(k * k // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
			for j in range(k * (k - 2 * (i & 1) + 4) // 3, n // 3 + flag, 2 * k):
				sieve[j >> 3] |= 1 << (j & 7)
	return sieve

def prime_list(n):
	res = []
	if n > 1:
		res.append(2)
	if n > 2:
		res.append(3)
	if n > 4:
		sieve = prime_sieve(n + 1)
		res.extend((3 * i + 1 | 1 for i in range(1, (n + 1) // 3 + (n % 6 == 1)) if not sieve[i >> 3] >> (i & 7) & 1))
	return res

def is_prime(n):
	if n < 5 or n & 1 == 0 or n % 3 == 0:
		return 2 <= n <= 3
	s = (n - 1 & 1 - n).bit_length() - 1
	d = n >> s
	for a in [2, 325, 9375, 28178, 450775, 9780504, 1795265022]:
		p = pow(a, d, n)
		if p == 1 or p == n - 1 or a % n == 0:
			continue
		for _ in range(s):
			p = p * p % n
			if p == n - 1:
				break
		else:
			return False
	return True

def all_factors(n):
	(small, large) = ([], [])
	for i in range(1, int(n ** 0.5) + 1, 2 if n & 1 else 1):
		if not n % i:
			small.append(i)
			large.append(n // i)
	large.reverse()
	small.extend(large)
	return small

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

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

def input():
	return sys.stdin.readline().strip()
n = int(input())
Arr = get_array()
if Arr[0] != 0:
	print(1)
	exit()
mini = 0
maxi = 0
count = 1
for i in range(1, n):
	if mini <= Arr[i] <= maxi + 1:
		count += 1
		maxi = max(maxi, Arr[i])
	else:
		break
if count == n:
	print(-1)
else:
	print(count + 1)


n = int(input())
A = list(map(int, input().split()))
max1 = 0
f = 0
if A[0] != 0:
	print(1)
	f = 1
if f == 0:
	for i in range(1, n):
		if A[i] > max1 + 1 and f == 0:
			print(i + 1)
			f = 1
		if A[i] > max1:
			max1 = A[i]
if f == 0:
	print(-1)


import collections
n = int(input())
a = [int(i) for i in input().split()]
ans = -1
t = 0
for i in range(0, n):
	if a[i] == t:
		t += 1
	elif a[i] > t:
		ans = i + 1
		break
if ans == -1:
	for i in range(0, n):
		if a[i] >= n:
			ans = i + 1
			break
print(ans)


for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	c = -1
	for i in range(n):
		if l[i] > c + 1:
			print(i + 1)
			break
		c = max(c, l[i])
	else:
		print(-1)


n = int(input())
daf = list(map(int, input().split()))
if daf[0] != 0:
	print(1)
else:
	max_num = 0
	for i in range(1, n):
		if daf[i] - max_num > 1:
			print(i + 1)
			break
		max_num = max(max_num, daf[i])
	else:
		print(-1)


n = int(input())
a = list(map(int, input().split()))
max_elem = 0
for i in range(n):
	if a[i] > max_elem:
		print(i + 1)
		exit()
	elif a[i] == max_elem:
		max_elem += 1
print(-1)


n = int(input())
ar = list(map(int, input().split()))
maxn = -1
flag = True
for i in range(1, n + 1):
	if ar[i - 1] < 0 or ar[i - 1] > maxn + 1:
		flag = False
		print(i)
		break
	if ar[i - 1] > maxn:
		maxn = ar[i - 1]
if flag:
	print(-1)


def solveB():
	n = int(input())
	N = list(map(int, input().rstrip().split()))
	mx = -1
	for (i, e) in enumerate(N):
		if not -1 < e < mx + 2:
			return i + 1
		if e > mx:
			mx = e
	return -1
print(solveB())


import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
if A[0] != 0:
	print(1)
	sys.exit()
MAX = 0
for i in range(1, N):
	if A[i] > MAX + 1:
		print(i + 1)
		sys.exit()
	elif A[i] == MAX + 1:
		MAX += 1
	else:
		continue
print(-1)


maxx = -1
n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
	if l[i] <= maxx:
		continue
	if l[i] == maxx + 1:
		maxx += 1
	else:
		print(i + 1)
		break
else:
	print('-1')


n = int(input())
num = list(map(int, input().split()))
fl = True
used = [False] * 110000
for i in range(n):
	if num[i] == 0:
		used[0] = True
		continue
	if num[i] > i or not used[num[i] - 1]:
		ans = i
		fl = False
		break
	else:
		used[num[i]] = True
if not fl:
	print(ans + 1)
else:
	print(-1)


n = int(input())
l = list(map(int, input().split()))
a = [0]
status = True
if l[0] == 0:
	for i in range(1, n):
		if l[i] > a[-1]:
			if l[i] == a[-1] + 1:
				a.append(l[i])
			else:
				print(i + 1)
				status = False
				break
else:
	print(1)
	status = False
if status:
	print(-1)


n = int(input())
arr = list(map(int, input().rstrip().split()))
used = set()
used.add(0)
used.add(1)
big = max(used)

def check(arr, big=big):
	if arr[0] != 0:
		print(str(1))
		return
	for i in range(1, len(arr)):
		if arr[i] in used:
			if arr[i] == big:
				used.add(arr[i] + 1)
				big = arr[i] + 1
			else:
				pass
		else:
			print(str(i + 1))
			return
	print(str(-1))
	return
check(arr)


maxElem = 0
n = int(input())
array = list(map(int, input().split()))
for (num, i) in enumerate(array):
	if i > maxElem:
		print(num + 1)
		exit(0)
	if i == maxElem:
		maxElem += 1
print('-1')


def check(st, item):
	if item == 0:
		return True
	if item - 1 in st:
		return True
	return False
n = int(input())
lst = list(map(int, input().split()))
st = set()
for (i, item) in enumerate(lst):
	if check(st, item):
		st.add(item)
	else:
		print(i + 1)
		exit()
print(-1)


n = int(input())
a = [int(s) for s in input().split()]
maximum = 0
count = 0
for i in range(len(a)):
	count += 1
	if a[i] == maximum:
		maximum += 1
	elif a[i] > maximum:
		print(count)
		break
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
	print(1)
else:
	max_a = 0
	for q in range(1, n):
		if a[q] > max_a + 1:
			print(q + 1)
			break
		elif a[q] == max_a + 1:
			max_a += 1
	else:
		print(-1)


n = int(input())
l = list(map(int, input().split(' ')))
if l[0] != 0:
	print('1', end='')
	exit()
max = 0
for i in range(1, n):
	if l[i] <= max:
		continue
	if l[i] == max + 1:
		max = max + 1
	else:
		print(i + 1, end='')
		exit()
print('-1', end='')


n = int(input())
a = list(map(int, input().split()))
ans = 0
if a[0] == 0 and len(a) == 1:
	print(-1)
elif a[0] != 0:
	print(1)
else:
	for i in range(1, len(a)):
		ans = max(a[i - 1], ans)
		if a[i] <= ans + 1:
			pass
		else:
			print(i + 1)
			break
		if i == len(a) - 1:
			print(-1)


import sys
n = int(input())
R = lambda : map(int, input().split())
lst = iter(R())
m = -1
for i in range(n):
	x = next(lst)
	if x > m + 1:
		print(i + 1)
		sys.exit()
	m = max(m, x)
print(-1)


n = int(input())
arr = list(map(int, input().split()))
arr1 = [arr[0]]
m = -1
for (i, v) in enumerate(arr):
	if v > m + 1:
		print(i + 1)
		break
	m = max(m, v)
else:
	print(-1)


n = int(input())
data = input().split()
max = 0
for i in range(n):
	back = max
	if max < int(data[i]):
		max = int(data[i])
	if i == 0 and data[i] != '0':
		print(1)
		exit()
	elif int(data[i]) > back + 1:
		print(i + 1)
		exit()
if int(data[i]) <= back + 1:
	print(-1)


n = int(input())
arr = list(map(int, input().split()))
curr = 0
t = -1
for (i, a) in enumerate(arr):
	if a == curr:
		curr += 1
	elif a > curr:
		t = i + 1
		break
print(t)


n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
	print(1)
	exit()
max1 = 0
for i in range(1, n):
	if a[i] > max1 + 1:
		print(i + 1)
		exit()
	max1 = max(max1, a[i])
print(-1)


n = int(input())
a = list(map(int, input().split(' ')))
flag = -1
if a[0] != 0:
	print('1')
	flag = 0
else:
	val = 0
	for i in range(1, n):
		if a[i] > val + 1:
			print(i + 1)
			flag = 0
			break
		else:
			val = max(val, a[i])
if flag == -1:
	print(-1)


n = int(input())
A = list(map(int, input().split()))
max = -1
ans = True
ind = 1
for a in A:
	if a > max + 1:
		ans = False
		break
	if a == max + 1:
		max = a
	ind += 1
print(-1 if ans else ind)


n = input()
array = [int(i) for i in input().split(' ')]
min_ = 0
max_ = 0
if array[0] != 0:
	print(1)
else:
	for (i, num) in enumerate(array[1:]):
		if num > max_ + 1:
			print(i + 2)
			break
		min_ = min(min_, num)
		max_ = max(max_, num)
	else:
		print(-1)


n = int(input())
A = list(map(int, input().split()))
now = -1
flag = True
for i in range(n):
	if A[i] > now + 1:
		print(i + 1)
		flag = False
		break
	elif A[i] == now + 1:
		now += 1
if flag:
	print(-1)


n = int(input())
mas = list(map(int, input().split()))
di = {}
from sys import exit
for (i, x) in enumerate(mas):
	if i == 0:
		if x != 0:
			print(1)
			exit()
		q = 0
	else:
		a = di.get(x)
		if a == None:
			if x - q > 1:
				print(i + 1)
				exit()
			q += 1
	di[x] = 0
print(-1)


n = int(input())
a = list(map(int, input().split()))
max_num = 0
err = False
for i in range(n):
	if a[i] == max_num:
		max_num += 1
	elif a[i] > max_num:
		err = True
		print(i + 1)
		break
if not err:
	print(-1)


a = int(input())
l = list(map(int, input().split()))
c = -1
ma = 0
if l[0] != 0:
	print('1')
else:
	for i in range(1, a):
		if l[i] <= ma + 1:
			if l[i] > ma:
				ma = l[i]
		else:
			c = i + 1
			break
	print(c)


from math import *
from copy import *
from string import *
from sys import stdin
from itertools import *
N = int(stdin.readline())
l = list(map(int, input().split()))
maxx_mex_possible = 0
ans = -1
if l[0] != 0:
	ans = 1
else:
	for i in range(1, N):
		if l[i] > maxx_mex_possible + 1:
			ans = i + 1
			break
		else:
			maxx_mex_possible = max(maxx_mex_possible, l[i])
print(ans)


import bisect
from sys import stdin, stdout
n = int(stdin.readline())
A = [int(i) for i in stdin.readline().split()]
ans = -1
if A[0] != 0:
	ans = 1
else:
	ma = A[0]
	for i in range(0, n - 1):
		if A[i + 1] > ma:
			if A[i + 1] - ma == 1:
				ans = -1
				ma = A[i + 1]
			else:
				ans = i + 2
				break
stdout.write(str(ans))


n = int(input())
max_ = -1
result = -1
for (idx, el) in enumerate(map(int, input().split())):
	if el <= max_ + 1:
		max_ = max(el, max_)
	else:
		result = idx + 1
		break
print(result)


t = int(input())
a = list(map(int, input().split()))
s = set()
for i in range(t):
	if a[i] - 1 in s or a[i] - 1 < 0:
		s.add(a[i])
	else:
		print(i + 1)
		exit()
print(-1)


n = int(input())
a = [int(i) for i in input().split()]
c = 0
for i in range(n):
	if a[i] > c:
		print(i + 1)
		break
	else:
		c = max(a[i] + 1, c)
else:
	print(-1)


rd = lambda : list(map(int, input().split()))
(n, a) = (rd()[0], rd())
maxa = -1
for (i, x) in enumerate(a):
	if x <= maxa + 1:
		maxa = max(maxa, x)
	else:
		print(i + 1)
		exit()
print(-1)


n = int(input())
s = [int(i) for i in input().split()]
m = -1
k = 0
for i in range(0, len(s)):
	if m + 1 < s[i]:
		print(i + 1)
		k = 1
		break
	elif m + 1 == s[i]:
		m += 1
if k == 0:
	print(-1)


n = int(input())
arr = list(map(int, input().split()))
if arr[0] != 0:
	print(1)
else:
	ind = -1
	max_ = 0
	for i in range(1, n):
		if arr[i] > max_ + 1:
			ind = i + 1
			break
		max_ = max(max_, arr[i])
	print(ind)


n = int(input())
m = list(map(int, input().split()))
s = 0
for i in range(n):
	if s < m[i]:
		print(i + 1)
		exit()
	elif s == m[i]:
		s += 1
print(-1)


from sys import stdin
nbr_steps = int(stdin.readline().strip())
orig_array = tuple(map(int, stdin.readline().strip().split()))

def solve():
	if orig_array[0] != 0:
		return 1
	possible = 1
	for (i, n) in enumerate(orig_array):
		if n < possible:
			continue
		elif n == possible:
			possible += 1
		elif n > possible:
			return i + 1
	return -1
print(solve())


n = int(input())
a = [int(el) for el in input().split()]
if a[0] != 0:
	print(1)
	raise SystemExit
cur = 0
t = 0
for i in range(1, n):
	if a[i] <= cur:
		continue
	if a[i] == cur + 1:
		cur = a[i]
		continue
	else:
		t = i + 1
		break
if t == 0:
	print(-1)
else:
	print(t)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	allow = 1
	for (i, val) in enumerate(a):
		if val < allow:
			allow = max(val + 2, allow)
		else:
			return i + 1
	return -1
print(main())


n = int(input())
l = list(map(int, input().split()))
flag = False
maxi = -1
for i in range(n):
	if l[i] > maxi + 1:
		flag = True
		break
	maxi = max(maxi, l[i])
if not flag:
	print(-1)
else:
	print(i + 1)


n = int(input())
mas = list(map(int, input().split()))
maxx = -1
f = 0
for i in range(n):
	if mas[i] > maxx:
		if mas[i] - 1 > maxx:
			print(i + 1)
			f = 1
			break
		else:
			maxx += 1
if f == 0:
	print(-1)


n = int(input())
l = list(map(int, input().split()))
m = l[0]
f = 0
for i in range(n):
	if l[i] > m + 1 or l[i] > i:
		f = 1
		print(i + 1)
		break
	if l[i] > m:
		m = l[i]
if f == 0:
	print(-1)


X = lambda : list(map(int, input().split()))
A = lambda : map(int, input().split())
B = lambda : int(input())
n = B()
a = X()
(ans, mx) = (0, -1)
for i in range(n):
	if not a[i] <= mx + 1:
		ans = i + 1
		break
	else:
		mx = max(mx, a[i])
print(-1 if not ans else ans)


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, **kwargs, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(N,) = getIntList()
za = getIntList()
now = 0
for i in range(N):
	if za[i] > now:
		print(i + 1)
		sys.exit()
	if za[i] == now:
		now += 1
print(-1)


input()
(s, r) = (0, -1)
for (i, x) in enumerate(map(int, input().split()), 1):
	if x > s:
		r = i
		break
	s += x == s
print(r)


n = int(input())
li = list(map(int, input().split()))
if n == 1 and li[0] == 0:
	print(-1)
else:
	c = 0
	d = {}
	if li[0] != 0:
		print(1)
	else:
		d.setdefault(0, 1)
		for i in range(1, n):
			d.setdefault(li[i], 0)
			if d[li[i]] == 0:
				if d.get(li[i] - 1):
					d[li[i]] = 1
				else:
					print(i + 1)
					c = 1
					break
		if c == 0:
			print(-1)


n = int(input())
a = list(map(int, input().split()))
i = 1
m = -1
ans = -1
for x in a:
	if x > m + 1:
		ans = i
		break
	else:
		i = i + 1
		m = max(m, x)
print(ans)


n = int(input())
l = input().split(' ')
l = [int(x) for x in l]
s = -1
for i in range(n):
	if l[i] > s + 1:
		print(i + 1)
		exit()
	elif l[i] == s + 1:
		s += 1
print(-1)


n = int(input())
l = list(map(int, input().split()))
z = l[0]
d = set({z})
if z != 0:
	print(1)
	exit()
else:
	flag = 0
	for i in range(1, n):
		if i == 0 and l[i] == 0:
			z = max(z, l[i])
			continue
		elif l[i] in d or z + 1 == l[i]:
			pass
		else:
			flag = 1
			break
		z = max(z, l[i])
		d.add(l[i])
	if flag == 1:
		print(i + 1)
	else:
		print(-1)


from collections import deque as de
import math
from sys import stdin, stdout
import re
from collections import Counter as cnt
from functools import reduce
from itertools import groupby as gb
from bisect import bisect_left as bl, bisect_right as br

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

class My_stack:

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

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

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

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

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

	def my_show_all(self):
		return self.data

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

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

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

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

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

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

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

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

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

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

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

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

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

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

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

def si():
	return list(map(int, input()))

def indict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic

def frqdict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		if int(value) not in dic:
			dic[int(value)] = 1
		else:
			dic[int(value)] += 1
	return dic
n = ii()
a = li()
if a[0] == 0:
	mx = 1
	for i in range(1, n):
		if a[i] > mx:
			print(i + 1)
			break
		elif a[i] == mx:
			mx += 1
	else:
		print(-1)
else:
	print(1)


n = int(input())
a = [int(s) for s in input().split(' ')]
m = 0
for i in range(n):
	if a[i] > m:
		print(i + 1)
		exit()
	elif a[i] == m:
		m += 1
print('-1')


n = int(input())
a = [int(x) for x in input().split()]
mex = 0
for x in range(0, n):
	if a[x] > x or a[x] > mex + 1:
		print(x + 1)
		exit(0)
	else:
		mex = max(mex, a[x])
print(-1)


step = int(input())
arrayVal = [int(item) for item in input().split(' ')]
maxMex = 0
for (i, item) in enumerate(arrayVal):
	if arrayVal[0] != 0:
		print(1)
		break
	elif item > maxMex + 1:
		print(i + 1)
		break
	elif i == step - 1:
		print(-1)
	maxMex = max(item, maxMex)


import sys
number = int(input())
array = [int(s) for s in input().split()]
max_ = 0
for i in range(len(array)):
	if array[i] == max_:
		max_ += 1
	elif array[i] < max_:
		pass
	else:
		print(i + 1)
		sys.exit(0)
print(-1)


n = int(input())
a = list(map(int, input().split()))
t = True
m = -1
for i in range(n):
	if a[i] > m + 1:
		t = False
		print(i + 1)
		break
	elif a[i] == m + 1:
		m = a[i]
if t:
	print(-1)


m = r = -1
for (i, x) in enumerate(map(int, [*open(0)][1].split())):
	if x > m + 1:
		r = i + 1
		break
	m = max(m, x)
print(r)


n = int(input())
a = list(map(int, input().split()))
maxi = -1
mb = True
for i in range(n):
	if a[i] - maxi > 1:
		mb = False
		print(i + 1)
		break
	maxi = max(a[i], maxi)
if mb:
	print(-1)


from math import ceil, sqrt
t = 1
for test in range(1, t + 1):
	n = int(input())
	a = list(map(int, input().split()))
	minim = -1
	ind = 0
	while ind < n:
		if a[ind] > minim + 1:
			break
		else:
			minim = max(a[ind], minim)
		ind += 1
	if ind == n:
		print(-1)
	else:
		print(ind + 1)


def inint():
	return int(input())

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

def main():
	n = inint()
	a = inlist()
	mx = 0
	if a[0] != 0:
		print(1)
		return
	for i in range(1, n):
		if a[i] > mx + 1:
			print(i + 1)
			return
		mx = a[i] if a[i] > mx else mx
	print(-1)
main()


from sys import exit
input()
m = 0
for (i, a) in enumerate(map(int, input().split())):
	if a > m:
		print(i + 1)
		exit(0)
	m = max(m, a + 1)
print(-1)


n = int(input())
b = list(map(int, input().split()))
if b[0] == 0:
	if len(b) > 1:
		c = 0
		for i in range(1, n):
			if b[i] > c + 1:
				print(i + 1)
				break
			elif i == n - 1:
				print(-1)
			elif b[i] > c:
				c = b[i]
	else:
		print(-1)
else:
	print(1)


n = int(input())
arr = list(map(int, input().split()))
max_now = -1
for (i, v) in enumerate(arr):
	if v > max_now + 1:
		print(i + 1)
		break
	if v == max_now + 1:
		max_now = v
	if i == len(arr) - 1:
		print(-1)


n = int(input())
a = [int(x) for x in input().split()]
if a[0] != 0:
	print(1)
else:
	t = -1
	mx = a[0]
	for i in range(n):
		if a[i] - 1 > mx:
			t = i + 1
			break
		elif a[i] > mx:
			mx = a[i]
	print(t)


b = int(input())
a = list(map(int, input().split()))
c = -1
for (i, el) in enumerate(a):
	if el - c > 1 or el < 0:
		print(i + 1)
		break
	if el > c:
		c = el
else:
	print(-1)


n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
	print('1')
else:
	k = 0
	m = 0
	for i in range(1, len(a)):
		if a[i] == m + 1 or a[i] <= m:
			k += 1
		else:
			print(i + 1)
			exit()
		if m < a[i]:
			m = a[i]
	if k == n - 1:
		print(-1)


R = lambda : list(map(int, input().split()))
n = int(input())
lst = R()
p = -1
q = -1
for i in range(0, n):
	if lst[i] > p + 1:
		print(i + 1)
		q = 1
		break
	p = max(lst[i], p)
if q == -1:
	print(q)


n = int(input())
L = list(map(int, input().split()))
ne = 0
d = {}
i = 0
while i < n:
	if L[i] not in d and ne != L[i]:
		print(i + 1)
		quit()
	elif ne == L[i]:
		d[L[i]] = 1
		ne += 1
	i += 1
print(-1)


n = int(input())
a = [int(x) for x in input().split(' ')]
seen = set()
mistake = -1
for i in range(len(a)):
	cur = a[i]
	seen.add(cur)
	if cur == 0:
		continue
	if cur - 1 not in seen:
		mistake = i
		break
print(-1 if mistake == -1 else mistake + 1)


def solution(n, a):
	arrayDistinct = set()
	for i in range(n):
		if a[i] == 0 or a[i] - 1 in arrayDistinct:
			arrayDistinct.add(a[i])
		else:
			return i + 1
	return -1

def test():
	print(solution(4, [0, 1, 2, 1]))
	print(solution(3, [1, 0, 1]))
	print(solution(4, [0, 1, 2, 239]))
n = int(input().strip())
a = list(map(int, input().strip().split(' ')))
print(solution(n, a))


x = int(input())
y = []
l = list(map(int, input().split()))
if len(l) != x or l[0] != 0:
	print(1)
	exit(0)
maxNum = 0
for i in range(x):
	if l[i] <= maxNum + 1:
		if maxNum + 1 == l[i]:
			maxNum += 1
	else:
		print(i + 1)
		exit(0)
print(-1)


n = int(input())
str = input().split()
d = 0
c = []
maxm = -1
for i in range(n):
	if maxm + 1 >= int(str[i]):
		if maxm <= int(str[i]):
			maxm = int(str[i])
	else:
		d = i + 1
		break
if d == 0:
	print('-1')
else:
	print(d)


input()
numbers = [int(x) for x in input().split()]
mex = 0
index = 1
ans = -1
for val in numbers:
	if val > mex:
		ans = index
		break
	elif val == mex:
		mex = mex + 1
	index = index + 1
print(ans)


n = int(input())
arr = list(map(int, input().split()))
flag = 0
if arr[0] != 0:
	flag = 1
i = 1
maxval = 0
while i < n and flag == 0:
	if arr[i] - maxval > 1:
		flag = 1
	maxval = max(arr[i], maxval)
	i += 1
if flag == 1:
	print(i)
else:
	print(-1)


import sys

def fi():
	return sys.stdin.readline()
n = int(fi())
l = list(map(int, input().split()))
d = dict()
if n == 1 and l[0] == 0:
	print(-1)
elif l[0] != 0:
	print(1)
else:
	d.setdefault(0, 1)
	for i in range(1, n):
		d.setdefault(l[i], 0)
		if d[l[i]] == 0:
			if d.get(l[i] - 1):
				d[l[i]] = 1
			else:
				print(i + 1)
				exit()
	print(-1)


n = int(input())
arr = list(map(int, input().split()))
s = set()
s.add(-1)
res = -1
for i in range(0, n):
	if arr[i] - 1 not in s:
		res = i + 1
		break
	else:
		s.add(arr[i])
print(res)


n = int(input())
a = [int(s) for s in input().split()]
c = set()
f = 1
flag = True
if a[0] == 0:
	c.add(1)
	c.add(0)
	for i in range(1, n):
		if not a[i] in c:
			print(i + 1)
			f = 0
			break
		c.add(a[i] + 1)
		if a[i] != 0:
			c.add(a[i] - 1)
	if f:
		print(-1)
else:
	print(1)


n = int(input())
numbers = [int(n) for n in input().split()]
ok = -1
ok2 = True
for i in range(len(numbers)):
	if numbers[i] > ok:
		if numbers[i] == ok + 1:
			ok += 1
		else:
			print(i + 1)
			ok2 = False
			break
if ok2:
	print(-1)


n = int(input())
a = [int(i) for i in input().split()]
mex = 0
ans = -1
for i in range(n):
	if a[i] > mex:
		ans = i + 1
		break
	if mex == a[i]:
		mex += 1
print(ans)


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

def qwe(a):
	f = -1
	for i in range(len(a)):
		if a[i] - f > 1:
			return i + 1
		elif a[i] - f == 1:
			f = a[i]
	return -1
print(qwe(a))


n = int(input())
a = [int(s) for s in input().split()]
mx = -1
ans = -1
for i in range(n):
	if a[i] > mx + 1:
		ans = i + 1
		break
	elif a[i] > mx:
		mx = a[i]
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
if n == 1:
	if a[0] == 0:
		print(-1)
	else:
		print(1)
else:
	maxi = 0
	done = 0
	for x in range(n):
		if x == 0:
			if a[x] != 0:
				print(x + 1)
				done = 1
				break
		elif a[x] > maxi + 1:
			print(x + 1)
			done = 1
			break
		if a[x] > maxi:
			maxi = a[x]
	if done == 0:
		print(-1)


n = int(input())
a = list(map(int, input().split()))
mistake = -1
m = -1
for i in range(n):
	if a[i] > m + 1:
		mistake = i + 1
		break
	m = max(m, a[i])
print(mistake)


n = int(input())
tmp = input().split()
arr = []
for i in tmp:
	arr.append(int(i))
dict = {}
f = 0
pos = 0
if arr[0] == 0:
	dict[0] = 1
	dict[1] = 1
	for i in range(1, n, 1):
		try:
			s = dict[arr[i]]
		except:
			s = 0
		if s:
			dict[arr[i] + 1] = 1
		else:
			pos = i + 1
			f = 1
			break
	if f:
		print(pos)
	else:
		print('-1')
else:
	print('1')


n = int(input())
a = list(map(int, input().split()))
m = -1
for (i, elem) in enumerate(a):
	if elem - m > 1 or elem < 0:
		print(i + 1)
		break
	if elem > m:
		m = elem
else:
	print(-1)


n = int(input())
a = []
if n == 0:
	print(0)
else:
	y = []
	y = [int(k) for k in input().split(' ')]
	if y[0] == 0:
		max = 0
		i = 1
		while i < n:
			if abs(max - y[i]) == 1 or max >= y[i]:
				if y[i] > max:
					max = y[i]
				i = i + 1
			else:
				break
		if i == n:
			print(-1)
		else:
			print(i + 1)
	else:
		print(1)


n = int(input())
a = list(map(int, input().split()))
mx = a[0]
k = 0
for i in range(len(a)):
	if a[i] > i or a[i] > mx + 1:
		print(i + 1)
		break
	else:
		k += 1
	if a[i] > mx:
		mx = a[i]
if k == n:
	print(-1)


n = int(input())
massive = list(map(int, input().split()))
res = -1
if massive[0] != 0:
	print(1)
else:
	max_of_list = 0
	i = 1
	while True:
		if i >= len(massive):
			break
		if massive[i] - max_of_list <= 1:
			if massive[i] > max_of_list:
				max_of_list = massive[i]
			i += 1
			continue
		else:
			res = i + 1
			break
	print(res)


inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))

def mex(arr):
	nList = set(arr)
	mex = 0
	while mex in nList:
		mex += 1
	return mex

def results(arr, n):
	i = 0
	max_ = arr[0]
	if arr[0] != 0:
		return 1
	while i < n:
		if arr[i] <= max_ + 1:
			max_ = max(max_, arr[i])
		else:
			return i + 1
		i += 1
	return -1

def main():
	n = inp()
	a = seq()
	result = results(a, n)
	print(result)
main()


import math
t = int(input())
l = list(map(int, input().split()))
c = -1
for i in range(0, len(l), 1):
	if l[i] > c + 1:
		print(i + 1)
		exit(0)
	c = max(c, l[i])
print(-1)


import math
n = int(input())
arr = list(map(int, input().split()))
f = 0
if arr[0] != 0:
	print(1)
	f = 1
elif n == 1:
	print(-1)
	f = 1
elif n > 1 and arr[1] > 1:
	print(2)
	f = 1
else:
	i = 2
	mm = arr[1]
	while i < n:
		if arr[i] > mm + 1:
			print(i + 1)
			f = 1
			break
		if arr[i] > mm:
			mm = arr[i]
		i += 1
if f == 0:
	print('-1')


n = int(input())
a = list(map(int, input().split()))
initial = 0
problem = False
for i in range(n):
	if a[i] == initial:
		initial += 1
	elif a[i] < initial:
		continue
	else:
		problem = True
		break
if problem == True:
	print(i + 1)
else:
	print(-1)