Problem:
Score : 800 points

Problem Statement

The beauty of a sequence a of length n is defined as a_1 \oplus \cdots \oplus a_n, where \oplus denotes the bitwise exclusive or (XOR).

You are given a sequence A of length N.
Snuke will insert zero or more partitions in A to divide it into some number of non-empty contiguous subsequences.

There are 2^{N-1} possible ways to insert partitions.
How many of them divide A into sequences whose beauties are all equal? Find this count modulo 10^{9}+7.

Constraints

All values in input are integers.

1 \leq N \leq 5 \times 10^5

0 \leq A_i < 2^{20}

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \ldots A_{N}

Output

Print the answer.

Sample Input 1

3
1 2 3

Sample Output 1

3

Four ways of dividing A shown below satisfy the condition. The condition is not satisfied only if A is divided into (1),(2),(3).

(1,2,3)

(1),(2,3)

(1,2),(3)

Sample Input 2

3
1 2 2

Sample Output 2

1

Sample Input 3

32
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Sample Output 3

147483634

Find the count modulo 10^{9}+7.

Sample Input 4

24
1 2 5 3 3 6 1 1 8 8 0 3 3 4 6 6 4 0 7 2 5 4 6 2

Sample Output 4

292

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>
#include <algorithm>
#include <string.h>
#include <vector>
using namespace std;
#define mod 1000000007
vector<int> v[(1<<20)];
int a[500005],tree[2000005],lazy[2000005];
void push(int node,int st,int en)
{
	tree[node]=(tree[node]+1LL*lazy[node]*(en-st+1))%mod;
	if (st!=en)
	{
		lazy[2*node]=(lazy[2*node]+lazy[node])%mod;
		lazy[2*node+1]=(lazy[2*node+1]+lazy[node])%mod;
	}
	lazy[node]=0;
}
void update(int node,int st,int en,int l,int r,int val)
{
	if (l<=st && en<=r)
	lazy[node]=(lazy[node]+val)%mod;
	push(node,st,en);
	if (en<l || st>r || r<l || (l<=st && en<=r))
	return;
	int mid=(st+en)/2;
	update(2*node,st,mid,l,r,val);
	update(2*node+1,mid+1,en,l,r,val);
	tree[node]=(tree[2*node]+tree[2*node+1])%mod;
}
int query(int node,int st,int en,int l,int r)
{
	push(node,st,en);
	if (en<l || st>r || r<l)
	return 0;
	if (l<=st && en<=r)
	return tree[node];
	int mid=(st+en)/2;
	return (query(2*node,st,mid,l,r)+query(2*node+1,mid+1,en,l,r))%mod;
}
int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		a[i]^=a[i-1];
	}
	for (int i=0;i<=n;i++)
	v[a[i]].push_back(i);
	int z=v[0].size();
	int ans=(z>1);
	for (int i=2;i<z;i++)
	ans=(ans*2)%mod;
	update(1,0,z-1,0,0,1);
	for (int i=1;i<(1<<20);i++)
	{
		for (int j:v[i])
		{
			int idx=upper_bound(v[0].begin(),v[0].end(),j)-v[0].begin();
			update(1,0,z-1,idx,z-1,query(1,0,z-1,0,idx-1));
		}
		if (!a[n])
		ans=(ans+query(1,0,z-1,z-1,z-1))%mod;
		if (a[n]==i)
		ans=(ans+query(1,0,z-1,0,z-1))%mod;
		reverse(v[i].begin(),v[i].end());
		for (int j:v[i])
		{
			int idx=upper_bound(v[0].begin(),v[0].end(),j)-v[0].begin();
			update(1,0,z-1,idx,z-1,mod-query(1,0,z-1,0,idx-1));
		}
	}
	printf("%d",ans);
}