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 Ruby (2.3.3) (judge verdict: Accepted)

N = gets.to_i
M = 10 ** 9 + 7

a_list = gets.strip.split(/ /).collect(&:to_i)

total = a_list.inject(:^)

zero_counts = []

x = 0
zero_count = 0
x_table = { 0=> [] }
a_list.each_with_index{|a, i|
	x ^= a
	if x == 0
		zero_count += 1
	end
	zero_counts << zero_count
	if l = x_table[x]
		l << i
	else
		x_table[x] = [i]
	end
}

r = x

count = 0

if r == 0
	count += (2 ** (x_table[0].length - 1)) % M
	x_table.each{|x, list|
		if x > 0
			cx = 1
			cz = 1
			prev = zero_counts[list[0]]
			list[1..-1].each{|i|
				z = zero_counts[i] - prev
				new_cx = (cz * z + cx) % M
				new_cz = (cz * (z + 1) + cx) % M
				cx = new_cx
				cz = new_cz
				prev = zero_counts[i]
			}
			count = (count + cz) % M
		end
	}
else
	if list = x_table[r]
		cx = 1
		cz = 1
		prev = zero_counts[list[0]]
		list[1..-1].each{|i|
			z = zero_counts[i] - prev
			new_cx = (cz * z + cx) % M
			new_cz = (cz * (z + 1) + cx) % M
			cx = new_cx
			cz = new_cz
			prev = zero_counts[i]
		}
		count = (count + cx) % M
	else
		count = 1
	end
end
puts count