#K34957. Maximum Bitwise AND of a Subset

    ID: 25424 Type: Default 1000ms 256MiB

Maximum Bitwise AND of a Subset

Maximum Bitwise AND of a Subset

You are given a list of n integers. Your task is to find the maximum possible value obtained by performing a bitwise AND operation on any subset of the list, where the subset must contain at least two numbers.

In other words, if you select any subset of the given integers with at least two elements and compute the bitwise AND (&) of all the numbers in that subset, what is the maximum value you can achieve?

Note: If the list contains only one integer, then no valid subset exists and the answer should be 0.

The constraints and input sizes are such that a greedy bit-by-bit approach can be used to solve the problem.

inputFormat

The input is read from standard input (stdin) and has the following format:

n
x1 x2 x3 ... xn

Here, n is the number of integers, and the next line contains n space-separated integers.

outputFormat

Output to standard output (stdout) a single integer — the maximum bitwise AND value of any subset of at least two numbers from the input list.

## sample
3
1 2 4
0

</p>