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 Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int n = nextInt();
		int[] A = nextIntArray(n);
		sc.close();
		int[] XorA = new int[n];
		XorA[0]=A[0];
		for(int i=0;i<n-1;i++)XorA[i+1] = XorA[i]^A[i+1];

		int INF = 20;
		long[] dp1 = new long[1<<INF];
		long[] dp0 = new long[1<<INF];
		long[] cnt = new long[1<<INF];
		Arrays.fill(dp0, 1);
		int zero=0;
		for (int i=0;i<n;i++) {
			if (XorA[i]==0) {
				zero++;
			} else {
				dp0[XorA[i]]+=dp1[XorA[i]]*(zero-cnt[XorA[i]]);
				dp1[XorA[i]]+=dp0[XorA[i]];
				dp0[XorA[i]]%=Mod;
				dp1[XorA[i]]%=Mod;

				cnt[XorA[i]]=zero;
			}
		}

		if (XorA[n-1]>0) {
			out.println(dp0[XorA[n-1]]);
		} else {
			long sum = 1;
			for (int i=0;i<zero-1;i++) {
				sum*=2;
				sum-=sum<Mod?0:Mod;
			}
			for (int i=0;i<(1<<INF);i++) {
				sum+=dp1[i];
				sum%=Mod;
			}
			out.println(sum);
		}
	}
	@SuppressWarnings("unused")
	private int min(int a, int b) {
		return Math.min(a, b);
	}
	private static int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	private static int nextInt() {
		return Integer.parseInt(next());
	}
	@SuppressWarnings("unused")
	private static long nextLong() {
		return Long.parseLong(next());
	}
	private static String next() {
		return sc.next();
	}
}