Trisle

Partition N powers into three nonempty groups to maximize the sum of the three XOR values.

Medium6Dynamic programmingBit manipulationMathNo attempts yetTime limit2sMemory limit512 MB

Problem

There are NN students. The power of each student is a small non-negative integer.

You want to split the students into three teams for a Trisle match. Every student belongs to exactly one team, and no team may be empty. Once the teams are fixed, the power of a team is the XOR of the powers of its members.

Hongjun calls the sum of the three team powers the greatness of the split. He wants to know how large that value can get. Write a program that finds the maximum possible greatness.

Input

The first line contains the number of students NN. (3N1003 \le N \le 100)

The second line contains the powers of the students X1,X2,,XNX_1, X_2, \dots, X_N, separated by spaces. (0Xi2550 \le X_i \le 255)

Output

Print the maximum possible greatness on the first line.

Hint

Suppose four students have powers 77, 33, 55 and 22. Put the student with power 77 alone on one team, the student with power 33 alone on another, and the remaining two students together. The greatness is then 7+3+(52)=177 + 3 + (5 \oplus 2) = 17.