QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓

#11104. Fish only have a three-second memory span

الإحصائيات

In this problem, you are given $n$ integers $a_1, a_2, \dots, a_n$. You want to perform exactly $n-1$ operations.

  • Choose two integers $x$ and $y$ from the sequence, remove them, and add the integer $x \oplus y$ to the sequence.
  • "$\oplus$" is the bitwise XOR operator. For example, $3 \oplus 5 = 6$, $15 \oplus 28 = 19$.

Performing only this operation is a bit boring, so at any time you can choose one integer from the sequence and add $1$ to it. You must perform this "add one" operation exactly once. Finally, the sequence will contain only one integer, and you want to maximize this remaining integer. Output the maximum possible value of this remaining integer.

Input

The first line contains an integer $n$ ($1 \le n \le 10^6$). The next line contains $n$ integers $a_1, a_2, \dots, a_n$ ($0 \le a_i < 2^{60}$).

Output

Output a single integer representing the maximum possible remaining value.

Examples

Input 1

4
1 2 1 2

Output 1

7

Input 2

5
1 2 3 4 5

Output 2

14

Input 3

6
1 2 4 7 15 31

Output 3

47

Note

In the first example, an optimal strategy is as follows:

  • Choose $1$ and $2$: $[1, 2, 1, 2] \to [1, 2, 3]$
  • Choose $1$ and $2$: $[1, 2, 3] \to [3, 3]$
  • Add $1$ to $3$: $[3, 3] \to [3, 4]$
  • Choose $3$ and $4$: $[3, 4] \to [7]$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.