Nasser and Bitwise OR Equal Array#12354

Nasser and Bitwise OR Equal Array

2 seconds
256 megabytes
Easy

Nasser was thinking about arrays and noticed he wanted to challenge himself with bitwise operations. He created the following task:

Nasser is given an array of integers, and he wants to make all the elements equal.

He can perform the following operation any number of times (possibly zero):

use xor basis

Here, the symbol | represents the bitwise OR operation. For two integers and , the result of is a number whose binary representation has a in each bit position where either or has a . For example, 5 \,|\, 3 = 7 because (101)_2 \,|\, (011)_2 = (111)_2.

Nasser asked himself:

"What is the minimum number of operations needed to make all the elements in the array equal?"

Input

Each test contains multiple test cases. The first line contains a single integer (1 \le t \le 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer (1 \le n \le 2 \cdot 10^5) — the size of the array.

The second line of each test case contains integers a_1, a_2, \ldots, a_n (1 \le a_i \le 10^9) — the elements of the array.

It is guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^5.

Output

For each test case, print a single integer — the minimum number of operations needed to make all the elements equal.

Examples

Example 1

Loading
Loading

Scoring

  1. Subtask ( points) : (1 \le a_i \le 2)

  2. Subtask ( points) : (a_i=2^k) i.e. a_i is a power of .

  3. Subtask ( points) : No additional constraints.