You are given n non-negative integer register values. Find the maximum bitwise XOR value over all unordered pairs of distinct positions (i, j) with i < j.
The intended approach inserts the numbers into a binary trie keyed by their bits from most significant to least significant; for each number, a greedy walk that prefers the opposite bit finds the best XOR partner among the numbers inserted so far.
Input format
Line 1: an integer n.
Line 2: n space-separated non-negative integers.
Output format
A single integer: the maximum XOR over all pairs.
Constraints
- 2 <= n <= 100000
- 0 <= each value <= 1000000000