C. OR-Max Segments
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Imran is working with arrays and bitwise operations. One day, he discovered an interesting property in subarrays. He calls a segment Cool if it satisfies a unique condition involving the maximum value and the bitwise OR of the elements.

You're given an array of integers $$$a$$$. A cool segment is a subarray $$$[l,r]$$$ such that: $$$$$$ \max(a_l, a_{l+1}, \dots, a_r) = a_l \,|\, a_{l+1} \,|\, \dots \,|\, a_r $$$$$$

In simple terms, the maximum value in the segment must be exactly equal to the bitwise OR of all the elements in that segment.

Your task is to count how many such cool segments exist in the array.

Input

The first line contains an integer $$$T$$$ $$$(1 \leq T \leq 10^3)$$$ — the number of test cases.

For each test case:

The first line contains an integer $$$n$$$ $$$(1 \leq n \leq 2 \cdot 10^5)$$$ — the number of elements in the array.

The second line contains $$$n$$$ space-separated integers $$$a_1, a_2, \cdots, a_n$$$ $$$(0 \leq a_i \lt 2^{30})$$$ — the elements of the array.

The total sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^5$$$

Output

For each test case, output a single integer — the number of cool segments in the array.

Example
Input
3
4
1 2 3 2
5
1 2 4 8 16
6
5 9 1 3 6 12
Output
9
5
8
Note

All Subarrays: $$$[1], [2], [3], [2], [1,2]$$$ (Not Cool), $$$[2,3], [3,2], [1,2,3], [2,3,2], [1,2,3,2]$$$

Total Cool Segments: $$$9$$$