#LC004. #D.种胡萝卜
#D.种胡萝卜
Title Description
The little white rabbit loves to eat carrots. It excavates the land into pits and arranges them in a row. From left to right, it presses the numbers to plant one carrot in each pit. Within N days, the little rabbit will choose a pit based on its mood to plant carrots. If it is already occupied, it will plant in the previous pit. If it is still occupied, the little white rabbit will search for empty pits until it finds an empty pit or finds no available pit ahead.
You originally needed to output rows, each row representing which pit the carrots for that day will be planted in (unable to plant output ), but to avoid output taking up too much time, you only need to output the result of (first day second day -th day ) )
Input format
The first line consists of two integers .
The next integers represent the pit chosen by the little rabbit on that day.
Output format
One line, one integer, meaning as described in the title
Example
5 8
7 7 1 6 1
42
Data scale and agreement
For data of , ;
For data of , ;
For data of , .