To test his divide and conquer abilities, Max decided to try a new technique of splitting his array,
- If the current segment is
element, return it. - Otherwise, split the current segment into
segments and apply the technique again on each segment. After applying the technique again, he will take the first segment and move it to the second segment's position, the second segment and move it to the third segment's position, and finally, the third segment and move it to the first segment's position. Finally, return this new segment.
If
Then, he will split each segment again:
Now, merge each segment based on those rules:
Finally, merge once more and get the final array:
Can you find the final array after applying this technique?
Constraints
Input Specification
The first line will contain an integer,
The second line will contain
Output Specification
Output the array after applying this technique.
Sample Input
Copy
9
1 2 3 4 5 6 7 8 9
Sample Output
Copy
9 7 8 3 1 2 6 4 5
Comments