Language: C++

// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

const int MOD = 1000000007;
//{{{ modular algebra
template<int mod=MOD>
struct Num{
	int v;
	Num(int n):v(n){}
	Num():v(0){}
	operator int() const {return v;}
	operator long long() const {return v;}
	template<class T>
	Num operator =(int n){v=n;return *this;}

	template<class T>
	inline void operator *=(const T &a) {
		v = (v*(long long)a)%mod;
	}
	template<class T>
	inline Num operator *(const T &a) {
		Num n(*this);n*=a;
		return n;
	}
	template<class T>
	inline void operator+=(const T &a){
		v+=(int)a;
		if(v>=mod)v-=mod;
		//	assert(0<=v and v<mod);
	}
	template<class T>
	inline Num operator+(const T &a){
		Num n(*this);n+=a;
		return n;
	}
	inline Num operator -(){
		if(v==0)return 0;
		else return Num(mod-v);
	}
	template<class T>
	inline void operator -=(const T &a){
		v-=(int)a;
		if(v<0)v+=mod;
	}
	template<class T>
	inline Num operator -(const T &a){
		Num n(*this);n-=a;
		return n;
	}
#ifdef __GCD_H
	inline Num inv(){
		return Num(invMod(this->v,mod));
	}
	template<class T>
	inline void operator /=(const T &a){
		(*this)*=invMod((int)a,mod);
	}
	template<class T>
	inline Num operator /(const T &a){
		Num n(*this);n/=a;
		return n;
	}
#endif
};

template<class T, int mod>
T& operator <<(T &os, const Num<mod> &n){
	os<<(int)n.v;
	return os;
}

template<class T, int mod>
T& operator >>(T &is, Num<mod> &n){
	is>>n.v;
	return is;
}
//}}}
typedef Num<MOD> mod_int;

//{{{ fact, binom, multinom
template<int mod=MOD>
inline Num<mod> fact(int n){
	static vector<Num<mod>> __fact(1,1);
	while(n>=(int)__fact.size())__fact.push_back(__fact.back()*__fact.size());
	return __fact[n];
}

template<int mod=MOD>
inline Num<mod> binom_memo(int n,int r){
	static vector<vector<Num<mod> > > __binom;
	if(n<0 or r<0 or n<r)return 0;
	while(n>=(int)__binom.size())__binom.push_back(vector<Num<mod> >(__binom.size()+1,-1));
	if((int)__binom[n][r]!=-1)return __binom[n][r];
	else if(r==0 or n==r)return __binom[n][r].v = 1;
	else return __binom[n][r] = binom_memo(n-1,r-1) + binom_memo(n-1,r);
}

#ifdef __GCD_H
template<int mod=MOD>
inline Num<mod> binom(int n,int r){
	if(n<0 or r<0 or n<r)return 0;
	Num<mod> fn = fact<mod>(n), fr = fact<mod>(r), fr2 = fact<mod>(n-r);
	//	return fact(n)/(fact(r)*fact(n-r));
	return fn/(fr*fr2);
}

template<int mod=MOD>
inline Num<mod> multinom(const vector<int> &v){
	Num<mod> num(fact<mod>(accumulate(ALL(v),0))), denom(1);
	REP(i,v.size())denom*=fact<mod>(v[i]);
	return num/denom;
}
#endif
//}}}

//{{{ mod_pow(Num<mod> x,Int k)
/* (x^k)%m */
template<int mod=MOD>
inline Num<mod> mod_pow(Num<mod> x, Int k){
	if(k==0) return 1;
	Num<mod> res(mod_pow(x,k/2));
	res*=res;
	if(k%2)res*=x;
	return res;
}
//}}}

int N;
vector<uint> A;

void naive(){
	unordered_map<int,int> ct;
	int ans = 0;
	uint B = (1u<<(N-1));
	for(uint b = 0;b < B;b++){
//		if(b%100000==0)dump(b,ans);
		vector<int> v;
		v.push_back(-1);
		REP(i,N-1)if(b&(1u<<i))v.push_back(i);
		v.push_back(N-1);
		bool first = true, valid = true;
		uint k = 0;
		for(int i = 0;i+1<v.size();i++){
			uint s = 0;
			for(int j = v[i] + 1;j <= v[i+1];j++){
				s^=A[j];
			}
			if(first){
				k = s;
				first = false;
			}else{
				if(k!=s){
					valid = false;
					break;
				}
			}
		}
		if(valid){
			ct[k]++;
//			dump(v,k);
			ans++;
		}
	}
	dump(ct);
	cout<<ans<<endl;
}

void solve(){
	vector<int> zero_count(N+1);
	uint s = 0;
	unordered_map<uint,vector<int> > a;
	zero_count[0] = 1;
	a[s].push_back(-1);
	for(int i = 0;i < A.size();i++){
		s ^= A[i];
		zero_count[i+1] = zero_count[i];
		if(s==0)zero_count[i+1]++;
		a[s].push_back(i);
	}
	mod_int ans = 0;
	for(auto &&p:a){
		auto &v = p.second;
		if(p.first==0){
			if(s==0){
				ans += mod_pow((mod_int)2,(int)v.size()-2);
			}
		}else{
			if(s==0 or (s!=0 and p.first==s)){
				int cur_zero = 0;
				mod_int sum0 = 1, dpk = 0;//sum0: ends with 0, dpk: ends with k
				for(int i = 0;i < v.size();i++){
					int zc = zero_count[v[i] + 1], zd = zc - cur_zero;
					sum0 += dpk * zd;
					dpk += sum0;
					cur_zero = zc;
				}
				if(s==0){
					ans += dpk;
				}else{
					ans += sum0;
				}
			}
		}
	}
	cout<<ans<<endl;
}
//ct = { (7, 1), (2, 5), (4, 9), (8, 1), (1, 3), (6, 2), (0, 256), (5, 9), (3, 6) }

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
    A.assign(N,Int());
    for(int i = 0 ; i < N ; i++){
        cin >> A[i];
    }
	solve();
//	naive();
	return 0;
}

//}}}



Compiler output:
a.cc: In function 'void naive()':
a.cc:206:9: error: 'dump' was not declared in this scope; did you mean 'dup'?
  206 |         dump(ct);
      |         ^~~~
      |         dup