#K11331. Maximum XOR Subarray

    ID: 23445 Type: Default 1000ms 256MiB

Maximum XOR Subarray

Maximum XOR Subarray

Given an array of integers, your task is to find the maximum XOR value of any contiguous subarray. In other words, if the array is \( a_1, a_2, \dots, a_n \), you need to compute:

$$ \max_{1 \leq i \leq j \leq n} (a_i \oplus a_{i+1} \oplus \dots \oplus a_j) $$

where \(\oplus\) denotes the bitwise XOR operation. Note that a subarray is a sequence of consecutive elements and may consist of a single element.

This problem requires careful use of cumulative XOR values and appropriate data structures to achieve an optimal solution.

inputFormat

The input begins with a line containing a single integer \(n\) which represents the number of elements in the array.

The second line contains \(n\) space-separated integers denoting the elements of the array.

outputFormat

Output a single integer, the maximum XOR value of any contiguous subarray.

## sample
4
1 2 3 4
7