9594: ABC245 —— B - Mex
[Creator : ]
Description
You are given a sequence of length $N$ consisting of integers: $A=(A_1,\ldots,A_N)$.
Find the smallest non-negative integer not in $(A_1,\ldots,A_N)$.
Find the smallest non-negative integer not in $(A_1,\ldots,A_N)$.
Input
Input is given from Standard Input in the following format:
```
$N$
$A_1$ $\ldots$ $A_N$
```
```
$N$
$A_1$ $\ldots$ $A_N$
```
Output
Print the answer.
Constraints
- $1 \leq N \leq 2000$
- $0 \leq A_i \leq 2000$
- All values in input are integers.
- $0 \leq A_i \leq 2000$
- All values in input are integers.
Sample 1 Input
8
0 3 2 6 2 1 0 0
Sample 1 Output
4
The non-negative integers are 0,1,2,3,4,…
We have 0,1,2,3 in A, but not 4, so the answer is 4.
We have 0,1,2,3 in A, but not 4, so the answer is 4.
Sample 2 Input
3
2000 2000 2000
Sample 2 Output
0