atcoder#ABC290C. [ABC290C] Max MEX
[ABC290C] Max MEX
Score : points
Problem Statement
You are given a length- sequence of non-negative integers. When is a sequence obtained by choosing elements from and concatenating them without changing the order, find the maximum possible value of .
Here, for a sequence , we define as the unique non-negative integer that satisfies the following conditions:
- Every integer such that is contained in .
- is not contained in .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
7 3
2 0 2 3 2 1 9
3
In this input, , and you obtain the sequence by picking elements. For example,
- If the -st, -nd, and -rd elements are chosen, .
- If the -rd, -th, and -th elements are chosen, .
- If the -nd, -th, and -th elements are chosen, .
- If the -nd, -rd, and -th elements are chosen, .
The maximum possible is .