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++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
#define lson x<<1
#define rson x<<1|1
#define mid ((l+r)>>1) 
int n,s[500100],sum[500100],zero[500100],f[500100],tag[2001000],res;
vector<int>v;
void pushdown(int x){
	tag[lson]+=tag[x],tag[rson]+=tag[x],tag[x]=0;
}
void update(int x,int l,int r,int P){
	if(l>P||r<P)return;
	if(l==r){(zero[P]+=1ll*tag[x]*sum[P]%mod)%=mod,tag[x]=0;return;}
	pushdown(x),update(lson,l,mid,P),update(rson,mid+1,r,P);
}
void read(int &x){
	x=0;
	char c=getchar(); 
	while(c>'9'||c<'0')c=getchar();
	while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();
}
int main(){
	read(n),f[0]=sum[0]=1;
	for(int i=1;i<=n;i++)read(s[i]),s[i]^=s[i-1],v.push_back(s[i]);
	sort(v.begin(),v.end()),v.resize(unique(v.begin(),v.end())-v.begin());
	for(int i=1;i<=n;i++)s[i]=lower_bound(v.begin(),v.end(),s[i])-v.begin(),zero[s[i]]=1;
	if(!v.front())v.erase(v.begin());
//	for(int i=1;i<=n;i++)printf("%d ",s[i]);puts("");
	if(!s[n]){
		for(int i=1;i<=n;i++)if(!s[i])f[i]=zero[0],(zero[0]+=f[i])%=mod;
		for(int i=1;i<=n;i++){
			if(!s[i])tag[1]++;
			else update(1,1,v.size(),s[i]),f[i]=zero[s[i]],(sum[s[i]]+=f[i])%=mod;
		}
		for(int i=1;i<=v.size();i++)(f[n]+=sum[i])%=mod;
		printf("%d\n",f[n]);
	}else{
		int s0=1,s1=0;
		for(int i=1;i<=n;i++){
			if(!s[i])f[i]=s1,(s0+=f[i])%=mod;
			if(s[i]==s[n])f[i]=s0,(s1+=f[i])%=mod;
		}
		printf("%d\n",f[n]);
	}
	return 0;
}
/*
3
1 2 3
3
1 2 2
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
5
1 5 4 2 3
50
0 0 1 1 0 0 1 1 2 2 0 0 3 3 0 0 1 2 3 0 0 3 3 1 3 2 0 0 0 0 0 0 0 1 2 3 0 0 1 1 2 2 3 2 0 1 0 0 0 0 
*/