Chaotic permutation
Today, Vasya was tasked with cleaning the classroom. Exhausted from tidying up, he decided he needed to create some chaos as a form of compensation. He then noticed a permutation of numbers from 1 to n written by the teacher on the board. A permutation of numbers from 1 to n is a sequence where each number from 1 to n appears exactly once.
Vasya considers three consecutive elements to be "in order" if they are arranged in either ascending or descending order. He defines a permutation as chaotic if none of the triplets of consecutive elements are in order.
Vasya wants to alter the permutation on the board to make it chaotic. To achieve this, he plans to swap two adjacent elements in the permutation up to n
times.
Help Vasya make the permutation chaotic before the teacher returns and scolds him for not cleaning.
Input
The board displays the initial permutation. The first line contains the integer n (3 ≤ n ≤ 1000), representing the length of the permutation. The second line contains n distinct integers, each ranging from 1 to n, representing the permutation itself.
Output
On the first line, output the number of operations k that Vasya needs to perform. On the second line, output k integers, each representing a swap operation. If you need to swap the i-th and i + 1-th elements of the permutation at a given step, output the number i.
If there are multiple valid solutions, you may output any of them. Note that minimizing the number of operations is not necessary, as long as it does not exceed n. If no solution exists, output -1.
Explanation of Examples
In the first example, the permutation changes as follows: (1 2 3 4 5) → (1 2 3 5 4) → (2 1 3 5 4) → (2 3 1 5 4). The solution provided in the second example is also valid. In the third example, the permutation is already chaotic, so no changes are needed.