SZ#TG#057. [CodeChef REBXOR] CodeChef REBXOR

提交0 通过0
通过率0%
时间限制1500ms
内存限制512MiB
    ID: 13572 传统题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 提高 上传者: 标签>信息学奥赛一本通提高篇第2部分 字符串算法(提高篇)第3章 Trie字典树题源:codechef

题目描述

Nikitosh the painter has a 1-indexed array A of N elements. He wants to find the maximum value of expression

(A[l1]A[l1 + 1]...A[r1]) + (A[l2]A[l2 + 1]...A[r2]) where 1l1r1 < l2r2N.

Here, xy means the bitwise XOR of x and y.

Because Nikitosh is a painter and not a mathematician, you need to help him in this task.

Input

The first line contains one integer N, denoting the number of elements in the array.

The second line contains N space-separated integers, denoting A1, A2, ... , AN.

Output

Output a single integer denoting the maximum possible value of the given expression.

Constraints

  • 2N4*105
  • 0Ai109

Subtasks

  • Subtask 1 (40 points) : 2N104
  • Subtask 2 (60 points) : Original constraints

Example

Input:
5
1 2 3 1 2

Output: 6

Explanation

</p>

Choose (l1, r1, l2, r2) = (1, 2, 3, 3) or (1, 2, 4, 5) or (3, 3, 4, 5).