You are given an integer $$$n$$$ which is a power of two and a permutation $$$a_1, a_2, \ldots, a_n$$$ of $$$0,1,\ldots,n-1$$$. In one operation you can do one of the following:
What is the minimal number of operations needed to sort the permutation?
Here XOR denotes the bitwise XOR operation.
The first line of the input contains a single integer $$$n$$$ ($$$1 \leq n \leq 2^{18}$$$, $$$n$$$ is a power of two) — the length of the permutation.
The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, $$$\ldots$$$ , $$$a_n$$$ which form a permutation of $$$0$$$, $$$1$$$, $$$\ldots$$$, $$$n-1$$$.
Output a single integer — the smallest number of operations needed to sort this permutation.
80 1 3 2 5 4 7 6
2
82 0 1 3 4 5 6 7
2
In the first sample, we can sort the permutation with two operations as follows:
In the second sample, we can sort the permutation with two operations as follows: