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# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	int[] G => ReadLine().Split().Select(int.Parse).ToArray();
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static T[] Recurse<T>(int n, T a0, Func<int, T, T> f) { var a = new T[n]; a[0] = a0; for (var i = 1; i < n; i++) a[i] = f(i, a[i - 1]); return a; }
	static T[] Accumulate<T>(IList<T> a, T zero, Func<T, T, T> f) { var s = new T[a.Count + 1]; s[0] = zero; for (var i = 0; i < a.Count; i++) s[i + 1] = f(s[i], a[i]); return s; }
	static int[] Accumulate(IList<int> a) { var s = new int[a.Count + 1]; for (var i = 0; i < a.Count; i++) s[i + 1] = s[i] + a[i]; return s; }
	const int MOD = 1000000007;
	public K()
	{
		var N = G[0];
		var A = G;
		var sum = Accumulate(A, 0, (a, b) => a ^ b);
		var zero = Accumulate(sum.Select(t => t == 0 ? 1 : 0).ToList());
		Func<IList<int>, int[]> getZero = l => MakeArray(l.Count - 1, i => zero[l[i + 1]] - zero[l[i]]);
		var dic = Indexes(sum);
		if (sum[N] != 0) WriteLine(DP(getZero(dic[-1])).Last());
		else
		{
			var ans = Pow(2, zero[N + 1] - 2, MOD);
			foreach (var t in dic) if (t.Key != 0) ans = (ans + DP(getZero(t.Value)).Sum()) % MOD;
			WriteLine(ans % MOD);
		}
	}
	static Dictionary<int, List<int>> Indexes(IList<int> x)
	{
		var dic = new Dictionary<int, List<int>>();
		for (var i = 0; i < x.Count; i++)
		{
			if (!dic.ContainsKey(x[i])) dic[x[i]] = new List<int>();
			dic[x[i]].Add(i);
		}
		return dic;
	}
	static long[] DP(IList<int> zs)
	{
		var L = zs.Count;
		var dp = new long[L + 1];
		dp[0] = 1;
		var sum = 1L;
		for (var j = 0; j < L; j++)
		{
			dp[j + 1] = (dp[j] + zs[j] * sum % MOD) % MOD;
			sum = (sum + dp[j + 1]) % MOD;
		}
		return dp;
	}
	public static long Pow(long a, long b, long mod)
	{
		long p = 1L, x = a;
		while (b > 0)
		{
			if ((b & 1L) == 1L) p = p * x % mod;
			b >>= 1;
			x = x * x % mod;
		}
		return p;
	}
}