SDE Path

Maximum XOR of Two Numbers Using a Trie

Hard

Maximum XOR of Two Numbers Using a Trie

Given an array of numbers, find the maximum XOR of any two elements using a bitwise trie.

Input format

The first line contains N (≥2). The second line contains N integers (0 ≤ a[i] < 2^20).

Output format

Print the maximum XOR of any two numbers.

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
15
9512 808247 929407 783455 919305 671774 536746 504271 346198 962950 610454 1007675 977243 753723 663408
Expected output
1016165
Example 2
Input
4
305728 965775 89172 772924
Expected output
1040603