CF2268C KiaKio and Energy Intervals
Description
Kia and Kio found a glowing array $ a_1, a_2, \ldots, a_n $ inside a crystal terminal in the ruins of an ancient digital kingdom.
The terminal works like this. Kia picks a segment of the array: any two indices $ l $ and $ r $ with $ l \lt r $ (so the segment always has at least two elements). Kio then finds the strongest energy in that segment, $ m = \max\left(a_l, a_{l+1}, \ldots, a_r\right) $ , and the terminal masks every element of the segment with $ m $ (bitwise AND), then fuses the results together (bitwise XOR):
$$$
(a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m).
$$$
That number is the energy released.
Kia wants the strongest possible blast. Over all valid segments $ (l, r) $ , what is the largest energy the terminal can produce?
Here, $ \& $ denotes the [bitwise AND](https://en.wikipedia.org/wiki/Bitwise_operation#AND) operation, and $ \oplus $ denotes the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation.
Input Format
Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 10^4 $ ). The description of the test cases follows.
The first line of each test case contains a single integer $ n $ ( $ 2 \le n \le 2\cdot10^5 $ ) — the size of the array.
The second line contains $ n $ integers $ a_1,a_2,\ldots,a_n $ ( $ 0 \le a_i \lt 2^{18} $ ).
It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2\cdot10^5 $ .
Output Format
For each test case, print a single integer — the maximum possible value of
$$$
(a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m)
$$$
among all pairs $ (l,r) $ satisfying $ l \lt r $ .
Explanation/Hint
In the first test case, one optimal interval is $ l=1 $ and $ r=2 $ . The maximum element in this interval is $ m=7 $ .
The value becomes $ (1\,\& \,7)\oplus(7\,\&\,7) = 6 $ .