#Q53. 「一本通 2.3 例 3」Nikitosh 和异或

「一本通 2.3 例 3」Nikitosh 和异或

Description

Original source: CODECHEF September Challenge 2015 REBXOR

Given an array AA of NN elements, indexed starting from 1. Find the maximum value of the following expression: $(A[l_1]\bigoplus A[l_1+1]\bigoplus …\bigoplus A[r_1])+ (A[l_2]\bigoplus A[l_2+1]^…\bigoplus A[r_2])$, where 1l1r1<l2r2N1\le l_1\le r_1<l_2\le r_2\le N, and xyx\bigoplus y denotes the bitwise XOR of xx and yy.

Input Format

The first line of input contains an integer NN, representing the number of elements in the array.

The second line contains NN integers A[1],A[2],,A[N]A[1], A[2], \ldots, A[N].

Output Format

Output a single line containing the maximum possible value of the given expression.

Sample 1

Valid (l1,r1,l2,r2)(l_1,r_1,l_2,r_2) pairs include: (1,2,3,3),(1,2,4,5),(3,3,4,5)(1,2,3,3),(1,2,4,5),(3,3,4,5).

5
1 2 3 1 2

6

Constraints and Hints

For 100%100\% of the data, 2N4×105,0Ai1092\le N \le 4\times 10^5, 0\le A_i\le 10^9.