Bob has a permutation
Constraints
In all subtasks:
Subtask 1 [10%]
You will receive full points in this subtask as long as the shift operations correctly sort the permutation within
For this subtask, it does not need to be sorted in the minimal number of shift operations.
Subtask 2 [50%]
Suppose
- If
, your score for this subtask is . - If
, your score for this subtask is - If
, your score for this subtask is .
For this subtask, it does not need to be sorted in the minimal number of shift operations.
Subtask 3 [40%]
You will receive full points in this subtask only if you sort the permutation in the minimal number of shift operations possible.
Input Specification
The first line contains one integer,
The second line contains
Output Specification
On the first line output
On the next
Failure to follow output specifications will result in a Wrong Answer verdict.
Sample Input 1
6
1 4 2 3 5 6
Sample Output 1
1
3 2 4 3
Sample Input 2
4
2 1 4 3
Sample Output 2
2
2 1 2
2 3 4
Comments