##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
5
1 1 0
4 1 1 0 3 2
5 2 0 2 1 0 4
6 3 3 3 0 1 2 6
7 4 1 2 0 4 3 6 5
2
2 3 4 5
2 4 4 5 6
1 2 4 4 5 7
2 4 5 6 7 8 9
We define the score of an array as follows.
Start with an empty set .
For each from to :
The second step can be used at most times in total. Here is the smallest non-negative integer that does not belong to .
The score of the array is the maximum possible value of after all elements are processed.
You are given an array . For each with , output the score of the prefix .
Here is the score of the prefix .
For the only prefix, we start with an empty set.
First, we insert , so . Then we use the operation and insert . Now , so the final mex is .
For the prefix , after inserting , we use the operation and insert . The final set contains and , so the score is .
For the prefix , first insert , then use the operation to insert . After that, the array also inserts . The final set contains and , so the score is .
For the prefix , first insert , then insert . After that, use the operation and insert . Finally, insert . The final set contains , so the score is .
For the prefix , the same operation after inserting gives . The final set contains , so the score is .
For the full prefix , use the first operation after inserting to insert . Then insert from the array. Use the second operation to insert . Finally, the array inserts . The final set contains , so the score is .
For the prefix , after inserting the first , use one operation to insert . After inserting the second , use another operation to insert . After inserting , use the last operation to insert . The final set contains , so the score is .
For the full prefix , use the operations after inserting the 3rd, 4th, 6th, and 7th elements.
After inserting , the set contains , so the operation inserts .
After inserting , the operation inserts .
After inserting , the operation inserts .
After inserting , the operation inserts .
So the final set contains all numbers from to , and the score is .