Question
Board Halve
Zara sees N numbers on a chalkboard. She can perform an operation only if all numbers are even: pick any number X and replace it with X/2. Determine the maximum number of such operations possible.
Input
The first line of the input contains a single integer N.
The second line of the input contains N space-separated integers.
The second line of the input contains N space-separated integers.
Output
Determine the maximum number of such operations possible.
Example
Sample Input
3
8 12 40
Sample Output
6
Sample Explanation
Initially, all three numbers are even, allowing us to perform an operation on any of them.
Operating on 40, it becomes 20.
Now the numbers are 20, 8, 12 – all still even.
Operating on 20 again, it becomes 10.
The numbers are now 10, 8, 12 – still all even.
Operating on 8, it becomes 4, then again 2, giving 10, 2, 12 – still all even.
Operating on 12, it becomes 6, giving 10, 2, 6 – still all even.
Finally, operating on any of these numbers leaves us with at least one odd number, after which no more operations are possible.
Thus, a total of 6 operations can be performed.
3
8 12 40
Sample Output
6
Sample Explanation
Initially, all three numbers are even, allowing us to perform an operation on any of them.
Operating on 40, it becomes 20.
Now the numbers are 20, 8, 12 – all still even.
Operating on 20 again, it becomes 10.
The numbers are now 10, 8, 12 – still all even.
Operating on 8, it becomes 4, then again 2, giving 10, 2, 12 – still all even.
Operating on 12, it becomes 6, giving 10, 2, 6 – still all even.
Finally, operating on any of these numbers leaves us with at least one odd number, after which no more operations are possible.
Thus, a total of 6 operations can be performed.