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.
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$$$
For each test case, output a single integer — the number of cool segments in the array.
341 2 3 251 2 4 8 1665 9 1 3 6 12
9 5 8
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$$$