Largest XOR using at most half the numbers

You are given N numbers, where N is even. Choose at most N/2 of them (from any positions) so that the XOR of the chosen numbers is as large as possible. Print that XOR.

Reported in: Infosys (SP / DSE · earlier papers) (memory-based)

Input

First line: N. Second line: N integers.

Output

The largest XOR.

Constraints

2 ≤ N ≤ 120, N even; 1 ≤ A[i] < 2^14.

Example 1

Input:
2
1 2

Output:
2

Example 2

Input:
4
2 4 6 8

Output:
14

Example 3

Input:
6
1 2 4 8 16 3

Output:
28

Hint: For every XOR value you can make, keep the fewest numbers needed to make it, adding the numbers one at a time like a 0/1 knapsack (the values fit in 2^14 slots). At the end take the largest value that needs at most N/2 numbers.

All coding practice