Question
Optimal XOR Partition

You have a sequence of numbers A of length N. The goal is to split this sequence into one or more non-empty, contiguous segments. For each segment, calculate the bitwise OR of the numbers within it. Then, find the minimum possible value of the bitwise XOR of all the segment results. What is the smallest XOR value you can achieve through an optimal division of the sequence?

Input
The first line of the input consists a single integer N.
The second line of the input consists of N space-separated integers A1 A2. .... AN.

Constraints
1 ≤ N ≤ 20
0 ≤ Ai < 230
Output
Print the smallest possible XOR value.
Example
Sample Input
3
1 5 7
Sample Output
2
Explanation
All possible combinations of non-empty segments are:
[1], [5], [7] => 1 ^ 5 ^ 7 = 3
[1, 5], [7] => (1 || 5) ^ 7 = 2
[1], [5, 7] => 1 ^ (5 || 7) = 6
[1, 5, 7] = 1 || 5 || 7 = 7

Online