P25771 [AtCoder] Mex
普及
题目描述

Problem Statement

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

Input

Input is given from Standard Input in the following format:
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.

Sample Input 1

8
0 3 2 6 2 1 0 0

Sample Output 1

4

The non-negative integers are $0,1,2,3,4,\ldots$.
We have 0,1,2,3 in A, but not 4, so the answer is 4.

Sample Input 2

3
2000 2000 2000

Sample Output 2

0

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
8 0 3 2 6 2 1 0 0
样例输出
4