This page is still under construction.

Parts of this page are still being built. What you see may change.

Trisle

Time limit2sMemory limit512 MB

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

Medium6 of 10

Topics
Dynamic programming, Bit manipulation, Math
Solved
No attempts yet

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. (3≤N≤1003 \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. (0≤Xi≤2550 \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+(5⊕2)=177 + 3 + (5 \oplus 2) = 17.

Examples2

  1. Example 1

    Input
    4
    7 3 5 2
    
    Expected output
    17
    
  2. Example 2

    Input
    3
    1 2 4
    
    Expected output
    7