G. Famous Smoothie
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Making the smoothie is a huge quest, during which you select $$$n$$$ ingredients, represented by numbers from $$$0$$$ to $$$10^9$$$, and arrange them in a sequence $$$a_i$$$. Repeating ingredients is allowed, meaning there could be $$$i$$$ and $$$j$$$ such that $$$a_i = a_j$$$.

Then you need to find the secret ingredient, the number of which is calculated as follows:

  1. For each $$$i$$$ from $$$1$$$ to $$$n$$$, for the sequence $$$a_1, \ldots, a_{i-1}, a_i$$$, determine $$$b_i$$$ — the smallest number that is not present in this sequence (denoted as $$$\mathrm{mex}(a_1, \ldots, a_i)$$$). For example, $$$\mathrm{mex}(1, 7, 2, 2, 0, 5, 4) = 3$$$ and $$$\mathrm{mex}(1, 4, 5, 2, 3) = 0$$$.
  2. From the resulting sequence $$$b_1, \ldots, b_n$$$, compute the mex again.
  3. The final value $$$\mathrm{mex}(b_1, \ldots, b_n)$$$ is taken as the number of the secret ingredient.

Obviously the order of these ingredients can change the number of the secret ingredient. It is known that the higher this number is, the more delicious the smoothie made with it will be.

Arrange the selected ingredients so that the corresponding number of the secret ingredient for the resulting sequence is as large as possible.

Input

The first line of input contains a single integer $$$n$$$ — the number of ingredients you have $$$(1 \leq n \leq 2 \cdot 10^5)$$$.

The second line lists $$$n$$$ integers from $$$0$$$ to $$$10^9$$$ — the numbers of these ingredients.

Output

Output a single integer — the maximum possible number of the secret ingredient.

Examples
Input
5
1 1 0 2 5
Output
4
Input
3
0 0 0
Output
0
Note

In the first example, one way to arrange the ingredients looks like $$$a = [5, 0, 1, 2, 1]$$$. In this case, we get $$$b = [0, 1, 2, 3, 3]$$$, the mex of which is $$$4$$$.