← Home
write a go solution for Description:
Yurii is sure he can do everything. Can he solve this task, though?

He has an array a consisting of n positive integers. Let's call a subarray a[l...r] good if the following conditions are simultaneously satisfied:

- l+1<=r-1, i. e. the subarray has length at least 3;
- (a_loplusa_r)=(a_l+1+a_l+2+ldots+a_r-2+a_r-1), where oplus denotes the bitwise XOR operation.

In other words, a subarray is good if the bitwise XOR of the two border elements is equal to the sum of the rest of the elements.

Yurii wants to calculate the total number of good subarrays. What is it equal to?

An array c is a subarray of an array d if c can be obtained from d by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

Input Format:
The first line contains a single integer n (3<=n<=2*10^5) — the length of a.

The second line contains n integers a_1,a_2,ldots,a_n (1<=qa_ilt2^30) — elements of a.

Output Format:
Output a single integer — the number of good subarrays.

Note:
There are 6 good subarrays in the example:

- [3,1,2] (twice) because (3oplus2)=1;
- [1,2,3] (twice) because (1oplus3)=2;
- [2,3,1] because (2oplus1)=3;
- [3,1,2,3,1,2,3,15] because (3oplus15)=(1+2+3+1+2+3).. Output only the code with no comments, explanation, or additional text.