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 <bits/stdc++.h>
#define pb push_back
#define LL long long
#define x first
#define y second
#define pii pair<int,int>
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
using namespace std;
int mod=1e9+7;	
LL f_pow(LL a,LL b){
	LL res=1,temp=a;
	while(b){
		if(b&1)res=res*temp%mod;
		temp=temp*temp%mod;
		b>>=1;
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	int a[500005];
	int tot=0;
	for(int i = 0;i<n;i++){
		scanf("%d",&a[i]);
		tot^=a[i];
	}
	int cnt=0;
	int now=0;
	map<int,int> m;
	//v.pb(map<int,int>());
	int lev=0;
	map<int,vector<pii> > ans;
	for(int i = 0;i<n;i++){
		now^=a[i];
		m[now]++;
		if(now==tot){
			cnt++;
			now=0;
			lev++;
			//v.pb(map<int,int>());
			for(auto it:m){
				if(it.x==0)
				continue;
				ans[it.x].pb(mp(it.y,lev));
			}
			m.clear();
		}
	}
//	printf("%lld\n",tot);
	if(tot==0){
		LL myans=0;

		for(auto it:ans){
			LL lastlev = 0;
			LL last=0;
			LL sum = 0;
			LL add=0;
			for(auto p :it.y){
				sum+=(p.y-lastlev-1)*last%mod;
			//	printf("%d ",sum);
				sum%=mod;
				last = (sum+1)*p.x%mod;
				lastlev = p.y;
				sum+=last;
				add+=last;
			//	printf("%d %d %d  ",p.x,p.y,sum);
			}
			//printf(" %d %d %d\n",last,sum,add);
			sum--;
			myans+=add;
		}
		printf("%lld\n",(f_pow(2,cnt-1)+myans)%mod);
	}
	else{
		LL temp[500005];
		temp[0]=1;
		LL odd=0,even=1;
		for(int i =1;i<=cnt;i++){
			if(i&1){
				temp[i]=even;
				odd+=temp[i];
				odd%=mod;
			}
			else{
				temp[i]=odd;
				even+=temp[i];
				even%=mod;
			}
		}
		printf("%lld\n",temp[cnt]);
	}
	return 0;
}
/*
n = x*m+x=x*(m+1);



*/