Power
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Barik has devised a problem for you, but decided that having 2 easy tasks in a contest is excessive. Thus, he presents you with the following challenge. You are given an array a consisting of N numbers. Your task is to find the maximum value of f(l1, r1, l2, r2), where:
[ f(l1, r1, l2, r2) = (a_{l1} \oplus a_{l1+1} \oplus \cdots \oplus a_{r1}) + (a_{l2} \oplus a_{l2+1} \oplus \cdots \oplus a_{r2}) ]
subject to the condition l1 ⩽ r1 < l2 ⩽ r2.
Input
The first line contains a single integer N (2 ⩽ N ⩽ 2 \times 10^5), representing the size of the array a.
The second line contains N integers a[1]
, a[2]
, ..., a[N]
where each a[i]
satisfies (1 ⩽ a[i] ⩽ 10^9) — these are the elements of the array a.
Output
Print a single integer — the maximum value of f.
Examples
Input #1
Answer #1
Submissions 18
Acceptance rate 17%