Under construction

Still being built. Things may change

XOR Sum 2

Time limit2sMemory limit512 MB

Summary
Pick any subsequence of up to 100,000 numbers under 10^18 so that the XOR of the chosen elements is maximum.
Level

Hard8 of 10

Topics
Bit manipulation, Greedy, Math
Solved
No attempts yet

Problem

You are given a sequence AA of NN numbers.

You want to choose a subsequence of AA. The XOR sum of a subsequence is the value obtained by XORing all of its elements together.

Given the sequence AA, write a program that finds the subsequence with the largest XOR sum.

Input

The first line contains the length of the sequence NN (1≤N≤100,0001 \le N \le 100{,}000). The second line contains the NN numbers of the sequence AA. Each number in AA is a positive integer less than or equal to 101810^{18}.

Output

Print the XOR sum of the subsequence of AA whose XOR sum is the largest.

Examples1

  1. Example 1

    Input
    3
    1 2 4
    
    Expected output
    7