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: Accepted)

#include <bits/stdc++.h>
#define MOD 1000000007
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
 
int A[500005];
vector <int> pos[500005];
int sum[500005];
 
int get(int s,int t)
{
	if(s>t) return 0;
	return sum[t]-sum[s-1];
}
int main()
{
	int n;
	scanf("%d",&n);
	vector <int> pxor;
	for(int i=1;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		A[i]=A[i-1]^x;
		pxor.push_back(A[i]);
	}
	pxor.push_back(0);
	sort(pxor.begin(),pxor.end());
	pxor.erase(unique(pxor.begin(),pxor.end()),pxor.end());
	
	for(int i=1;i<=n;i++)
	{
		A[i]=lower_bound(pxor.begin(),pxor.end(),A[i])-pxor.begin();
		pos[A[i]].push_back(i);
		sum[i]=sum[i-1]+(A[i]==0);
	}
	//for(int i=0;i<n;i++) printf("%d ",A[i]);puts("");
	ll ret=0;
	if(A[n]==0)//all 0
	{
		int cnt=pos[0].size()-1;
		ret=1;
		for(int i=0;i<cnt;i++) ret=ret*2LL%MOD;
	}
	
	for(int i=1;i<pxor.size();i++)
	{
		if(A[n]!=0&&A[n]!=i) continue;
		ll odd=0,even=1;
		int bef=0;
		for(int j=0;j<pos[i].size();j++)
		{
			int to=pos[i][j];
			even+=odd*(ll) get(bef,to-1)%MOD;
			if(even>=MOD) even-=MOD;
			odd+=even;
			if(odd>=MOD) odd-=MOD;
			bef=to+1;
		}
		if(A[n]==0)
		{
			ret+=odd;
			ret%=MOD;
		}
		else
		{
			ret+=even;
			ret%=MOD;
		}
	}
	printf("%lld\n",ret);
}