409218: GYM103462 J Jew Sorting

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Jew Sortingtime limit per test2.5 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

Hello, guys, I am the King of boredom.

I have a array of length $$$2^k(0 \leq k \leq 20)$$$. You can delete the first half or the second half of each operation.

So, you need to tell me the minimum number of operations required can make this sequence non-decreasing.

Input

The first line contains a single integer $$$k(0 \leq k \leq 20)$$$, denoting the length of the array is $$$2^k$$$.

The second line contains $$$2^k$$$ integers, the $$$i$$$-th integer is $$$a_i(1 \leq a_i \leq 10^9)$$$ representing the array.

Output

Print a single integer, denoting the answer.

ExamplesInput
2
1 3 2 1
Output
1
Input
2
1 2 3 4
Output
0

加入题单

算法标签: