Type: Default 1000ms 512MiB

异或

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

给定一个含 NN 个元素的数组 AA,下标从 11 开始。请找出下面式子的最大值:$(A[l_1]\oplus A[l_1+1]\oplus \dots \oplus A[r_1])+ (A[l_2]\oplus A[l_2+1] \oplus \dots\oplus A[r_2])$,其中1l1r1<l2r2N 1\le l_1\le r_1<l_2\le r_2\le Nxyx\oplus y 表示 xxyy 的按位异或。

输入格式

输入数据的第一行包含一个整数 NN,表示数组中的元素个数。

第二行包含 NN 个整数 A[1],A[2],,A[N]A[1],A[2],\ldots ,A[N]

输出格式

输出一行包含给定表达式可能的最大值。

5
1 2 3 1 2
6

样例解释

满足条件的 (l1,r1,l2,r2)(l_1,r_1,l_2,r_2) 有:(1,2,3,3),(1,2,4,5),(3,3,4,5)(1,2,3,3),(1,2,4,5),(3,3,4,5)

数据规模与约定

对于 100%100\% 的数据,2N4×105,0Ai1092\le N \le 4\times 10^5, 0\le A_i\le 10^9