#arc173e. E - Rearrange and Adjacent XOR

E - Rearrange and Adjacent XOR

Score: 800800 points

问题陈述

给定一个由 NN 个非负整数组成的序列 A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N)。考虑对这个序列执行以下操作 N1N-1 次,以获得长度为 11 的序列:

  • nnAA 的长度。首先,你可以随意重新排列 AA 中的元素。然后,用一个由 n1n-1 个非负整数组成的序列 $(A_1 \oplus A_2, A_2 \oplus A_3, \dots, A_{n-1} \oplus A_n)$ 替换 AA

这里,\oplus 表示按位 XOR\mathrm{XOR} 操作。

XX 为在执行了 N1N-1 次操作后得到的、长度为 11 的序列中的项的值。找出 XX 的最大可能值。

什么是按位 XOR\mathrm{XOR} 操作?

两个非负整数 AABB 的按位 XOR\mathrm{XOR},记作 ABA \oplus B,定义如下:

  • ABA \oplus B 的二进制表示中,2k2^kk0k \geq 0)位上的数字如果是 11,则当且仅当在 AABB2k2^k 位上是 11 但不是两者都是 11 时,它就是 11;否则是 00

例如,35=63 \oplus 5 = 6(二进制:011101=110011 \oplus 101 = 110)。 一般来说,kk 个非负整数 p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k 的按位 XOR\mathrm{XOR} 定义为 $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$,并且可以证明这与 p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k 的顺序无关。

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given a sequence of NN non-negative integers A=(A1,A2,,AN)A=(A_1,A_2,\dots,A_N). Consider performing the following operation N1N-1 times on this sequence to obtain a sequence of length 11:

  • Let nn be the length of AA. First, rearrange the elements in AA in any order you like. Then, replace AA with a sequence of n1n-1 non-negative integers $(A_1 \oplus A_2, A_2 \oplus A_3, \dots, A_{n-1} \oplus A_n)$.

Here, \oplus represents the bitwise XOR\mathrm{XOR} operation.

Let XX be the value of the term contained in the sequence of length 11 obtained after N1N-1 operations. Find the maximum possible value of XX.

What is the bitwise XOR\mathrm{XOR} operation?

The bitwise XOR\mathrm{XOR} of two non-negative integers AA and BB, denoted as ABA \oplus B, is defined as follows:

  • In the binary representation of ABA \oplus B, the digit at the 2k2^k (k0k \geq 0) position is 11 if the digit at the 2k2^k position is 11 in AA or BB but not both, and 00 otherwise.

For example, 35=63 \oplus 5 = 6 (in binary: 011101=110011 \oplus 101 = 110).
In general, the bitwise XOR\mathrm{XOR} of kk non-negative integers p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k is defined as $(\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k)$, and it can be proved that this does not depend on the order of p1,p2,p3,,pkp_1, p_2, p_3, \dots, p_k.

Constraints

  • 2N1002 \leq N \leq 100
  • 0Ai<2600 \leq A_i < 2^{60}
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \dots ANA_N

Output

Print the answer.

Sample Input 1

4
1 2 3 4

Sample Output 1

7

The sequence AA can be transformed into A=(7)A=(7) by the following three operations:

  • In the first operation, rearrange A=(1,2,3,4)A=(1,2,3,4) to (3,1,4,2)(3,1,4,2). AA is replaced with (31,14,42)=(2,5,6)(3 \oplus 1, 1 \oplus 4, 4 \oplus 2) = (2,5,6).
  • In the second operation, rearrange A=(2,5,6)A=(2,5,6) to (2,6,5)(2,6,5). AA is replaced with (26,65)=(4,3)(2 \oplus 6, 6 \oplus 5) = (4,3).
  • In the third operation, rearrange A=(4,3)A=(4,3) to (4,3)(4,3). AA is replaced with (43)=(7)(4 \oplus 3) = (7).

Sample Input 2

13
451745518671773958 43800508384422957 153019271028231120 577708532586013562 133532134450358663 619750463276496276 615201966367277237 943395749975730789 813856754125382728 705285621476908966 912241698686715427 951219919930656543 124032597374298654

Sample Output 2

1152905479775702586