Prefix & Suffix Maximization

ashraful9194 RUET CodeSmash 2020
Limits 1s, 256 MB

You are given an array aa of nn integers. Now, let’s define two variables PP and SS. Where PP is the bitwise XOR value of all elements for any non-empty prefix. And SS is the bitwise XOR value of all elements for any non-empty suffix. Now find the maximum value of (P&S)(P \& S). Where &\& denotes the bitwise AND operation.

Note that, the sum of the length of chosen prefix and suffix has to be less than or equal to nn.

Input

The first line of the input contains one integer n (2n106)n \ (2≤n≤10^6) denoting the number of elements of the array.

The next line contains n space-separated integers a1,a2,,an(1ai109)a_1 ​ ,a_2 ​ ,…,a_n ​ (1≤a_i ​≤10^9 ) denoting the elements of the array.

Output

Print the maximum value of (P&S)(P \& S) as described in the statement.

Samples

InputOutput
2
12 12
12
InputOutput
4
2 4 2 4
6

Submit

Login to submit.

Statistics

67% Solution Ratio
sayeef006Earliest, 1M ago
sayeef006Fastest, 0.1s
sayeef006Lightest, 18 MB
sayeef006Shortest, 1789B
Toph uses cookies. By continuing you agree to our Cookie Policy.