The Duel of Spells

Time limit: 2 secMemory limit: 256 MBData Structures, Math

Problem Statement

In the ancient realm of Eldoria, mighty wizards gather to duel using the potent energy of their spells. Each spell is imbued with a unique magic number, and it is believed that the more powerful the combination of two spells, the stronger the resulting force. The power of two spells is determined by computing the bitwise XOR of their magic numbers.

Now, as the kingdom teeters on the brink of chaos, you have been tasked with aiding a renowned wizard in selecting the two spells from his collection that yield the maximum possible magic power. Given a list of nn spells with their respective magic numbers, your task is to determine the highest value obtainable by performing the bitwise XOR on any two distinct spells.

Your journey through the arcane art of computation begins now!

Input Format

  • The first line contains an integer nn (2n1052 \leq n \leq 10^5), representing the number of spells.
  • The second line contains nn space-separated positive integers, where each integer denotes the magic number associated with a spell.

Output Format

  • Output a single integer — the maximum XOR value of any pair of spells from the list.

Examples

Input

3
1 2 3

Output

3

Input

4
4 6 7 8

Output

15

Code Editor

Submit a solution. Authentication is required to create submissions.

Language
Theme
Source code is submitted to the judge for testing.