#P7197. Multiply 2 Divide 2
Multiply 2 Divide 2
Problem Description
$\textbf{Note:There is no dependency between this problem and problem Hack of Multiply 2 Divide 2.}$
Frank_DD has a sequence $a$ of length $n$.
For each operation, he selects a number $a_i(1 \le i \le n)$ and changes it to $a_i\cdot 2$ or $\lfloor \frac{a_i}{2} \rfloor$.
Frank_DD wants to know the minimum number of operations to change the sequence $a$ to a non-descending sequence.
Input
The first line of the input contains one integer $T$ $($$1\leq T\leq 5$ $)$ --- the number of test cases. Then $T$ test cases follow.
In each test case:
The first line contains a single integer $n(1 \leq n \leq 10^5)$ --- the length of sequence $a$.
The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ $(1 \leq a_i \leq 10^5)$ --- the sequence $a$.
Output
For each test case, print a single integer in a single line --- the minimum number of operations to change the sequence $a$ to a non-descending sequence.
2
7
6 3 3 4 10 8 2
10
9 9 4 7 3 10 10 8 4 3
4
11
Hint
In the first test case, we can use at least 4 operations to change the sequence $a$ to a non-descending sequence:
$a_1=\lfloor \frac{a_1}{2} \rfloor$
$a_5=\lfloor \frac{a_5}{2} \rfloor$
$a_7=a_7 \cdot 2$
$a_7=a_7 \cdot 2$