#P7003. Checksum Subarrays
Checksum Subarrays
Checksum Subarrays
Pavel is sending an array of non-negative integers to his friend Egor. To ensure that the array has not been tampered with, Pavel calculates a checksum by counting the number of subarrays for which the bitwise XOR of the subarray equals the bitwise AND of the subarray.
For a subarray consisting of elements \(a_l, a_{l+1}, \dots, a_r\), let
\[ X = a_l \oplus a_{l+1} \oplus \dots \oplus a_r, \quad Y = a_l \land a_{l+1} \land \dots \land a_r. \]The subarray is considered valid if \(X = Y\). Note that for any single element subarray, the condition always holds.
Your task is to compute the number of subarrays that satisfy \(X = Y\).
inputFormat
The first line contains a single integer \(n\) — the number of elements in the array.
The second line contains \(n\) non-negative integers separated by spaces.
outputFormat
Output a single integer representing the number of subarrays for which the bitwise XOR equals the bitwise AND.
sample
4
1 2 3 3
6
</p>