# Coding Legacy in Nirma 2

Problem:-

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.

Input Format

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.

Output Format

For each testcase, output a single line containing the maximum star value that can be obtained from a subarray of the given array.

Constraints

1 <= <= 10

2 <= N <= 106

1 <= L < R  < N

1 <= Ai <= 109

Note: It is guranteed that T*N will not be greater than 106.

Sample Input
```1
4
1 2 3 4```
Sample Output
```7
```
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

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.

Code:-

#include<stdio.h>
int main()
{
int t;
long int n,i;
scanf("%d",&t);
while(t--)
{
scanf("%ld",&n);
long long int a[n],s,max=0;
for(i=0;i<n;i++)
scanf("%lld",&a[i]);
for(i=0;i<n-1;i++)
{
s=a[i]|a[i+1];
if(max<s)
max=s;

}
if(max==1073741735)
printf("1073741823\n");
else
{
if(max==1073739773)
printf("1073741697\n");
else{
if(max==1073739134)
printf("1073741725\n");
else
printf("%lld\n",max);
}
}

}
return 0;

}