Parking - MarisaOJ: Marisa Online Judge

Parking

Time limit: 1000 ms
Memory limit: 256 MB
There are $n$ slots on a circular parking enumerated from $1$ to $n$. There are $n$ cars that want to park in the natural order. $i^{th}$ car wants to park at ${p_i}^{th}$ slot. If the car drives to a parking slot and her slot is occupied, it drives in a circular manner and parks on the first vacant slot. ### Input - The first line contains integer $n$, the size of the parking and the number of cars. - The second line contains $n$ integers, the slot that wants to be occupied by car $i$. ### Output Output $n$ numbers. $i^{th}$ number should be the parking slot which was occupied by $i^{th}$ car. ### Constraints - $1 \le n \le 10^5$. - $1 \le p_i \le n$. ### Example Input: ``` 3 2 2 2 ``` Output: ``` 2 3 1 ```