P13611 [CodeChef] taand
提高-
题目描述

Given an array of n non-negative integers: A1, A2, …, AN. Your mission is finding a pair of integers Au, Av (1 ≤ u < v ≤ N) such that (Au and Av) is as large as possible.
And is a bit-wise operation which is corresponding to & in C++ and Java.

Input
The first line of the input contains a single integer N. The ith line in the next N lines contains the Ai.

Output
Contains a single integer which is the largest value of Au and Av where 1 ≤ u < v ≤ N.

Constraints
50 points:

2 ≤ N ≤ 5000
0 ≤ Ai ≤ 10^9

50 points:

2 ≤ N ≤ 3 × 10^5
0 ≤ Ai ≤ 10^9

Example
Input:
4
2
4
8
10

Output:
8

Explanation

2 and 4 = 0
2 and 8 = 0
2 and 10 = 2
4 and 8 = 0
4 and 10 = 0
8 and 10 = 8

输入格式

见题面

输出格式

见题面

样例输入
4 2 4 8 10
样例输出
8