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: Wrong Answer)

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	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 int ArgMax<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) < 0) { m = a[i]; mi = i; } return mi; }
	static int ArgMin<T>(IList<T> a) where T : IComparable<T> { var m = a[0]; var mi = 0; for (var i = 1; i < a.Count; i++) if (m.CompareTo(a[i]) > 0) { m = a[i]; mi = i; } return mi; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var A = G;
		var sum = Recurse(N + 1, 0, (i, a) => a ^ A[i - 1]);
		var zero = Recurse(N + 2, 0, (i, a) => a + (sum[i - 1] == 0 ? 1 : 0));
		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[0])).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;
	}
}