Hardik and Sanket are two coding legends who played a crucial part in improving the competitive programming culture in Nirma. As a matter of legacy, the same thing was passed on to next batch with more strength. In order to test the current scenario at Nirma, they asked the following problem:
You are given an array A having N distinct elements. You can select any contiguous subarray of length greater than 1. The star value of a subarray is the bitwise OR of the smallest and second smallest element in that subarray. You need to find the maximum star value that can be obtained among all the subarrays of the array.
The first line contains the number of test cases T.
Each test case is as follows:
The first line contains N, the number of elements.
The second line has N space seperated integers Ai.
For each testcase, output a single line containing the maximum star value that can be obtained from a subarray of the given array.
1 <= T <= 10
2 <= N <= 106
1 <= L < R < N
1 <= Ai <= 109
Note: It is guranteed that T*N will not be greater than 106.
For subarray [3,4], minimum element is 3 and second minimum is 4, whose BITWISE OR is 7 (3 OR 4), which is the maximum possible value among all the subarrays.