Loading...
XOR-dinary Adventure!
Time: 1 s
Memory: 128 MB
In Whitechapel, London, there is a famous treasure map that contains several numbers. The map’s value is determined by the XOR of all the numbers along its path. One day, Mr. Heart, an adventurer, finds the last remaining treasure map, but he faces a challenge. Two explorers, Kamona and Wasim, want to share the map, but since there is only one map left, Mr. Heart must decide how to split it. He plans to cut the map into two parts: one part for Kamona and another part for Wasim. The two parts must be contiguous subarrays of the original map, meaning both Kamona and Wasim must select continuous sequences of numbers from the array. The two parts must not overlap, meaning no number can appear in both parts, but one or both parts can be empty.

The value of the treasure map for each explorer is the XOR of the numbers in their respective parts. If an explorer gets no part of the map, the value is zero. Mr. Heart wants to maximize the total value (the XOR of both parts). Your task is to find the best way to cut the map to maximize the combined value.
Input
The first line contains an integer value \(N \; (1 ≤ N < 10^5)\).
The second line contais \(N\) integers \(A_1, A_2, \dots, A_N \; (0 ≤ A_i ≤ 10 ^ {12})\).
Output
Output the maximum possible total value after splitting the map into two contiguous subarrays.
Examples
Input
Output
4
1 2 3 4
7
Input
Output
3
1 2 3
3
Problem Info
Problem ID 362
Time Limit 1000 ms
Memory Limit 131072 KB
Moderators punter
Statistics
Submit
You need to Login or Registration for submit your solution