Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/bit-eng-katta-xor-toplam

Largest subset XOR

Hard 1000 ms 128 MB 95%
Share

$n$ non-negative integers are given. We choose any subset of them (it may be empty, its XOR is $0$) and compute the XOR of its elements. Find the largest XOR value. For example, for $9, 8, 5$ the largest is $8 \oplus 5 = 13$.

Binary representations of the numbers; the chosen subset is highlighted and its XOR is below

Input

The first line contains a positive integer $n$. The second line contains $n$ integers $a_{i}$.

Output

One integer — the largest XOR.

Note

$1 \le n \le 10^{5}$
$0 \le a_{i} \lt 2^{60}$

Examples

Input #1
3
9 8 5
Output #1
13
Input #2
1
0
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.