Maximum XOR Pair
You are given n non-negative integers a_1, a_2, ..., a_n. Choose two different indices i and j and compute a_i XOR a_j, where XOR is the bitwise exclusive or. Find the largest value this can take.
The two indices must be different, but the values at them may be equal.
Input
The first line contains an integer n (2 ≤ n ≤ 2·10^5).
The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i < 2^30).
Output
Print one integer: the maximum of a_i XOR a_j over all pairs of indices i ≠ j.
Notes
In the first example, 5 XOR 25 = 00101 XOR 11001 = 11100 = 28 in binary, and no other pair does better.
In the second example, the largest number is 12, but pairing it with anything gives at most 8; the best pair is 11 XOR 4 = 15.