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 PyPy3 (2.4.0) (judge verdict: Wrong Answer)

mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
n = max(A).bit_length()
S = [0]*N
for i, a in enumerate(A):
    S[i]=S[i-1]^a
index = [[-1] for _ in range(2<<n)]
cumsum = [0]*(N+1)
for i, s in enumerate(S):
    index[s].append(i)
    cumsum[i] = cumsum[i-1]
    if s == 0:
        cumsum[i]+=1
ans = 0
if S[-1] == 0:
    for i in range(1, 1<<n):
        l = len(index[i])
        if l == 1:
            continue
        dp = [0]*(l-1)
        dp_cum = [0]*(l-1)
        for j, k in enumerate(index[i][1:]):
            dp[j] = (dp_cum[j-1]*(cumsum[k]-cumsum[index[i][j]])+1)%mod
            dp_cum[j] = (dp_cum[j-1]+dp[j])%mod
        ans+=dp_cum[-1]
        ans%=mod
    ans+=pow(2, cumsum[N-1]-1, mod)
    ans%=mod
else:
    l = len(index[S[-1]])
    dp = [0]*(l-1)
    dp_cum = [0]*(l-1)
    for j, k in enumerate(index[S[-1]][1:]):
        dp[j] = (dp_cum[j-1]*(cumsum[k]-cumsum[index[S[-1]][j]])+1)%mod
        dp_cum[j] = (dp_cum[j-1]+dp[j])%mod
    ans = dp[-1]%mod
print(ans)