E. OIer's Dream(Chaser)
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

You are given an array $$$a$$$ of $$$n$$$ integers. Find:

$$$$$$\max_{1 \le i,j \le n} \gcd(a_i,a_j) + (a_i \oplus a_j)$$$$$$

where $$$\oplus$$$ denotes the bitwise XOR operation.

Input

The first line of each test contains an integer $$$n$$$ ($$$1 \le n \le 5 \cdot 10 ^5$$$) — the length of $$$a$$$.

The second line contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le 5 \cdot 10^5$$$) — the elements of $$$a$$$.

Output

Output an integer representing the maximum value of the expression above.

Examples
Input
3
1 2 3
Output
4
Input
5
9 9 3 8 2
Output
13