In the beautiful capital of Dmojistan, there are banks and a single policeman. The banks are numbered from to . You managed to find the policeman's schedule for the next days. It turns out that on the day, he will be protecting bank .
Armed with this information, you are planning to rob all banks in the next days. You will rob bank on the day. A robbery will be successful if the cop is not protecting that bank on that day (that is, ).
Before you can start robbing, you need to determine a sequence which will work. Output a sequence which will rob all banks or if it is not possible to rob all banks. The sequence should be integers from to .
Any valid sequence will be accepted.
Constraints
Subtask 1 [50%]
Subtask 2 [50%]
Input Specification
The first line will contain .
The next line will contain space-separated integers .
Output Specification
Output a valid sequence if it is possible or if it is not. The sequence should be integers from to .
Sample Input
5
2 1 1 1 1
Sample Output
1 2 3 4 5
Comments
I don't know what's getting me tle on the second subtask. Any ideas as to why this is happening?
Your algorithm appears to be (due to ArrayDeque.contains()).
Thanks for the feedback :)