Under construction

Still being built. Things may change

Deception

Time limit1sMemory limit256 MB

Summary
You divide the numbers into two nonempty groups with equal XOR to make the first group's sum as large as possible.
Level

Medium5 of 10

Topics
Bit manipulation, Greedy
Solved
No attempts yet

Problem

Seunghyun likes tricking people. Today he wants to trick us with a sequence.

Seunghyun brought a sequence of nn natural numbers a1,a2,…,ana_1, a_2, \dots, a_n. He then tells us to put each element of the sequence into group X or group Y. Call the elements of X X1,X2,…,XkX_1, X_2, \dots, X_k and the elements of Y Y1,Y2,…,Yn−kY_1, Y_2, \dots, Y_{n-k}. Neither group may be empty, so k>0k > 0 and n−k>0n - k > 0.

If X1⊕X2⊕⋯⊕XkX_1 \oplus X_2 \oplus \dots \oplus X_k equals Y1⊕Y2⊕⋯⊕Yn−kY_1 \oplus Y_2 \oplus \dots \oplus Y_{n-k}, Seunghyun pays us X1+X2+⋯+XkX_1 + X_2 + \dots + X_k won.

He has tricked us so often that we do not believe him, but there is no way to lose money here, so we will try once. Given the sequence aa that Seunghyun presents, write a program that decides whether we can get paid, and if we can, finds the largest amount.

⊕\oplus is the bitwise exclusive or (XOR). Write both numbers in binary, then put 1 in each position where the two bits differ and 0 where they are the same.

Input

The first line contains nn (1≤n≤10001 \le n \le 1000). The second line contains a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1061 \le a_i \le 10^6), separated by spaces.

Output

Print the largest amount of money you can receive on the first line. Print 0 if you cannot receive any money.

Examples2

  1. Example 1

    Input
    3
    1 2 3
    
    Expected output
    5
    
  2. Example 2

    Input
    4
    1 2 3 4
    
    Expected output
    0