##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
For a sequence of integers, its mex is the smallest non-negative integer that does not appear in the sequence.
For example, the mex of is , because does not appear in the sequence.
The mex of is , because , , and appear, but does not appear.
You are given an array and an integer .
Your goal is to make the mex of the array as large as possible.
In one operation, you can choose an index and replace with .
You may perform this operation any number of times, possibly zero. You may also apply the operation to the same element more than once.
Find the maximum possible mex of the array.
The array already contains , so the mex is at least . Since there is no unused element that can become , the mex cannot be larger.
The second copy of each of can be increased by . Then the array can contain all values from to .