Under construction

Still being built. Things may change

Mavis at School

Time limit3sMemory limit1024 MB

Summary
Given an array, find the segment whose maximum times its XOR sum is largest, and print that product.
Level

Hard8 of 10

Topics
Divide and conquer, Stack, Prefix sum, Trie
Solved
No attempts yet

Problem

Once upon a time, Mavis studied at a vampire school. In computer science lessons, Mavis solved problems on various topics. One of her favorite topics is arrays.

Today is the array test at the vampire school. Mavis gets this problem: given an array aia_i, find a segment [l..r][l..r] that maximizes max(l..r)×xor(l..r)max(l..r) \times xor(l..r).

max(l..r)max(l..r) is the largest number in the segment [l..r][l..r], and xor(l..r)xor(l..r) is the ⊕\oplus sum of the numbers in that segment.

Help Mavis solve this problem, because she really does not want to disappoint Dracula.

Input

The first line contains a natural number nn (1≤n≤1051 \le n \le 10^5). The next line contains nn numbers aia_i (1≤ai≤1061 \le a_i \le 10^6), the array Mavis has.

Output

Print one integer on the first line: the largest value of max(l..r)×xor(l..r)max(l..r) \times xor(l..r) that can be found in the array.

Hint

In the first sample, the answer is the segment [2..4][2..4].

In the second sample, the answer is the segment [5..6][5..6].

Examples2

  1. Example 1

    Input
    4
    1 2 10 7
    
    Expected output
    150
    
  2. Example 2

    Input
    6
    2 3 5 3 6 8
    
    Expected output
    112