#P1438E. Yurii Can Do Everything

    ID: 5650 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>binary searchbitmasksbrute forceconstructive algorithmsdivide and conquertwo pointers*2500

Yurii Can Do Everything

No submission language available for this problem.

Description

Yurii is sure he can do everything. Can he solve this task, though?

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

  • l+1r1l+1 \leq r-1, i. e. the subarray has length at least 33;
  • (alar)=(al+1+al+2++ar2+ar1)(a_l \oplus a_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 cc is a subarray of an array dd if cc can be obtained from dd by deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

The first line contains a single integer nn (3n21053 \leq n \leq 2\cdot 10^5) — the length of aa.

The second line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai<2301 \leq a_i \lt 2^{30}) — elements of aa.

Output a single integer — the number of good subarrays.

Input

The first line contains a single integer nn (3n21053 \leq n \leq 2\cdot 10^5) — the length of aa.

The second line contains nn integers a1,a2,,ana_1,a_2,\ldots,a_n (1ai<2301 \leq a_i \lt 2^{30}) — elements of aa.

Output

Output a single integer — the number of good subarrays.

Samples

Sample Input 1

8
3 1 2 3 1 2 3 15

Sample Output 1

6

Sample Input 2

10
997230370 58052053 240970544 715275815 250707702 156801523 44100666 64791577 43523002 480196854

Sample Output 2

2

Note

There are 66 good subarrays in the example:

  • [3,1,2][3,1,2] (twice) because (32)=1(3 \oplus 2) = 1;
  • [1,2,3][1,2,3] (twice) because (13)=2(1 \oplus 3) = 2;
  • [2,3,1][2,3,1] because (21)=3(2 \oplus 1) = 3;
  • [3,1,2,3,1,2,3,15][3,1,2,3,1,2,3,15] because (315)=(1+2+3+1+2+3)(3 \oplus 15) = (1+2+3+1+2+3).