#abc304g. [abc304_g]Max of Medians
[abc304_g]Max of Medians
Problem Statement
You are given a sequence of length : .
Find the maximum value that can be obtained as the median of the length- sequence $(A_1 \\oplus A_2, A_3 \\oplus A_4, \\ldots, A_{2N-1} \\oplus A_{2N})$ by rearranging the elements of the sequence .
Here, represents bitwise exclusive OR.
What is bitwise exclusive OR? The bitwise exclusive OR of non-negative integers and , denoted as , is defined as follows:
- The number at the position () in the binary representation of is if and only if exactly one of the numbers at the position in the binary representation of and is , and it is otherwise.
For example, (in binary notation: ).
Also, for a sequence of length , the median of is the value at the -th position of the sequence obtained by sorting in ascending order.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4
4 0 0 11 2 7 9 5
Sample Output 1
14
By rearranging as , we get $(A_1 \\oplus A_2, A_3 \\oplus A_4, A_5 \\oplus A_6, A_7 \\oplus A_8) = (5, 14, 15, 2)$, and the median of this sequence is .
It is impossible to rearrange so that the median of $(A_1 \\oplus A_2, A_3 \\oplus A_4, A_5 \\oplus A_6, A_7 \\oplus A_8)$ is or greater, so we print .
Sample Input 2
1
998244353 1000000007
Sample Output 2
1755654
Sample Input 3
5
1 2 4 8 16 32 64 128 256 512
Sample Output 3
192