Felix6326727/beyond-accuracy-code-comprehension huggingface dataset:
N=int(input())
A=[int(i) for i in input().split()]
B=[A[0]]
mod=10**9+7
for i in range(1,N):
  B.append(B[-1]^A[i])
#print(B)
if B[-1]:
  table=[]
  for i in range(N):
    if B[i]==B[-1]:
      if table:
        if table[-1][0]==1:
          table[-1]=(1,table[-1][1]+1)
        else:
          table.append((1,1))
      else:
        table.append((1,1))
    elif B[i]==0:
      if table:
        if table[-1][0]==0:
          table[-1]=(0,table[-1][1]+1)
        else:
          table.append((0,1))
      else:
        table.append((0,1))
  l=len(table)
  dp=[[0]*2 for i in range(l+1)]
  dp[0][0]=1
  for i in range(l):
    if table[i][0]==1:
      dp[i+1][0]=dp[i][0]
      dp[i+1][1]=(dp[i][1]+dp[i][0]*table[i][1])%mod
    else:
      dp[i+1][1]=dp[i][1]
      dp[i+1][0]=(dp[i][0]+dp[i][1]*table[i][1])%mod
  #print(dp)
  #print(table)
  print(dp[l-1][0]) 
else:
  table=[[] for i in range(2**20)]
  List=[]
  used=[False]*(2**20)
  ans=5*(10**8)+4
  for i in range(N):
    if B[i]!=0:
      if not used[B[i]]:
        List.append(B[i])
        used[B[i]]=True
      if table[B[i]]:
        if table[B[i]][-1][0]==1:
          table[B[i]][-1]=(1,table[B[i]][-1][1]+1)
        else:
          table[B[i]].append((1,1))
      else:
        table[B[i]].append((1,1))
    elif B[i]==0:
      ans=(ans*2)%mod
      for k in List:
        if table[k]:
          if table[k][-1][0]==0:
            table[k][-1]=(0,table[k][-1][1]+1)
          else:
            table[k].append((0,1))
        else:
          table[k].append((0,1))
  for k in List:
    l=len(table[k])
    dp=[[0]*2 for i in range(l+1)]
    dp[0][0]=1
    for i in range(l):
      if table[k][i][0]==1:
        dp[i+1][0]=dp[i][0]
        dp[i+1][1]=(dp[i][1]+dp[i][0]*table[k][i][1])%mod
      else:
        dp[i+1][1]=dp[i][1]
        dp[i+1][0]=(dp[i][0]+dp[i][1]*table[k][i][1])%mod
    ans=(ans+dp[l-1][1])%mod
  #print(table)
  print(ans%mod)
  

# Example run
# Input:
-32942311
298151
# Output:
1
MOD = 10 ** 9 + 7

N = int(input())
a = list(map(int, input().split()))
ma = max(a)

cum_xor = [0] * (N + 1)
for i, aa in enumerate(a):
    cum_xor[i + 1] = cum_xor[i] ^ aa
# print(cum_xor)

d = [[] for _ in range(ma + 1)]

for i in range(0, ma + 1):
    tar = i
    cnt = 0
    for j in range(1, N + 1):
        if cum_xor[j] == tar:
            if cnt > 0:
                d[i].append(cnt)
                cnt = 0
            d[i].append(0)
            tar ^= i
        elif cum_xor[j] == (tar ^ i):
            cnt += 1
if cnt > 0:
    d[i].append(cnt)
    cnt = 0


def rec(cur):
    if cur < 0: return 0
    if cur == 0:
        return 1
    mul = 1
    # print(kkk, cur)
    if d[kkk][cur] > 0:
        mul = (d[kkk][cur] + 1)
        
    if mm[cur]:
        return mm[cur]
    res = 0
    for i in range(cur - 1, -1, -2):
        res += mul * rec(i)
        mul = 1
    return res


ans = 0
if d[0].count(0) == 0:
    pass
elif d[0].count(0) == 1:
    ans += 1
else:
    ans += 1 << (d[0].count(0) - 1)
for kkk in range(1, ma + 1):
    lg_di = len(d[kkk])
    mm = [None] * (N + 1)
    ans += rec(lg_di - 1)
    ans %= MOD
    # print(d[i])
print(ans)


# Example run
# Input:
1
188176
# Output:
1
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]])+1)%mod
        dp_cum[j] = (dp_cum[j-1]+dp[j])%mod
    ans = dp[-1]%mod
print(ans)

        



# Example run
# Input:
17
618445
# Output:
32769
N = int(input())
a = list(map(int,input().split(" ")))
mod = 10**9 + 7

allxor = 0
tmpxor = 0
idx = [ ]
value = { }
for i in range(N):
    allxor ^= a[i]
    tmpxor ^= a[i]
    if not tmpxor in value:
        value[tmpxor] = 1
    else:
        value[tmpxor] += 2

    if tmpxor == 0:
        idx.append(i)

if allxor != 0:
    cnt = 0
    tmpxor = 0
    for i in range(N):
        tmpxor ^= a[i]
        if tmpxor == allxor:
            cnt += 1
            tmpxor = 0
    
    print(pow(2,cnt,mod))
    exit(0)

l = len(idx)
ans = pow(2, l-1, mod)

for key,value in value.items():
    if key == 0:
        continue
    if value == 1:
        ans += 1
    else:
        ans += (value%3) * ( pow(2, value//3) - 1) + 1
print(ans)





# Example run
# Input:
-126905272
28016
# Output:
500000004
# input
N = int(input())
A = list(map(int, input().split()))

MOD = 10 ** 9 + 7

dp = [[None for _ in range(N)] for __ in range(N+1)]
dp[0] = [0 for _ in range(N)]

def xors(i, j):
    xor = A[i-1]
    for k in range(i,j):
        xor ^= A[k]
    return xor


for i in range(1, N+1):
    dp[i][0] = 1
    for j in range(1,i):
        dp[i][j] = 0
        for k in range(j):
            if xors(k+1, j) == xors(j+1, i):
                dp[i][j] += dp[j][k]

print(sum(dp[-1]) % MOD)


# Example run
# Input:
0
-119796
# Output:
0
n = int(input())
A = list(map(int, input().split()))

from collections import defaultdict

x = 0
dict = defaultdict(int)
cnt = defaultdict(int)

for a in A:
    x ^= a
    if x == 0:
        dict[x] += 1
    else:
        dict[x] += 1
        if cnt[x] == 0:
            cnt[x] = 1
        else:
            cnt[x] *= max(1, dict[0] - cnt[x])

ans = 2 ** (dict[0] - 1) + sum(dict.values()) + sum(cnt.values()) - n

mod = 10 ** 9 + 7

print(ans % mod)

# Example run
# Input:
-902193
6
# Output:
902195.5
def cul(n):
    memo[1]=1
    memo[2]=1
    memo[3]=2
    if memo[n]==-1:
        t=1
        for i in range(1,N):
            t+=cul(N-i)
        memo[n]=t
    return memo[n]

import math
import sys
MOD=10**9+7

N=int(input())
memo=[-1]*(N+3)

tmp=0
l=[-1]
a=list(map(int,input().split()))
b=[]
x=[]
for i in range(N):
    tmp=tmp ^ a[i]
    x.append(tmp)
    if tmp==0:
        b.append([x[i] for i in range(len(x))])
        x=[]
if x!=[]: b.append([x[i] for i in range(len(x))])

M=tmp
if tmp!=0:
    tmp=0
    s=0
    for i in range(N):
        tmp=tmp^a[i]
        if tmp==M: s+=1
    print(cul(s))
    sys.exit()   

# Example run
# Input:
-420
627
# Output:
from collections import defaultdict
mod=10**9+7
n=int(input())
A=tuple(map(int,input().split()))
Acc=[0]*n
for i,a in enumerate(A):
    if i==0:
        Acc[0]=a
    else:
        Acc[i]=Acc[i-1]^a

def solve(Acc):
    total_0=0
    dp_0=defaultdict(lambda: 1)
    dp_x=defaultdict(int)
    cnt_0=defaultdict(int)
    for a in Acc:
        if a:
            if a not in dp_x:
                dp_x[a]=1
                cnt_0[a]=total_0
            else:
                dp_0[a]=(dp_0[a]+dp_x[a]*(total_0-cnt_0[a]))%mod
                cnt_0[a]=total_0
                dp_x[a]=(dp_x[a]+dp_0[a])%mod
        else:
            total_0+=1
    if Acc[-1]:
        return dp_0[Acc[-1]]
    return (sum(dp_x.values())+pow(2,total_0-1,mod))%mod

print(solve(Acc))

# Example run
# Input:
5330
3
# Output:
40121808
def cul(n):
    memo[1]=1
    memo[2]=1
    memo[3]=2
    if memo[n]==-1:
        t=1
        for i in range(1,N):
            t+=cul(N-i)
        memo[n]=t
    return memo[n]

import math
import sys
MOD=10**9+7

N=int(input())
memo=[-1]*(N+3)

tmp=0
l=[-1]
a=list(map(int,input().split()))
b=[]
x=[]
for i in range(N):
    tmp=tmp ^ a[i]
    x.append(tmp)
    if tmp==0:
        b.append([x[i] for i in range(len(x))])
        x=[]
if x!=[]: b.append([x[i] for i in range(len(x))])

M=tmp
if tmp!=0:
    tmp=0
    s=0
    for i in range(N):
        tmp=tmp^a[i]
        if tmp==M: s+=1
    print(cul(s))
    sys.exit()   

# Example run
# Input:
-473
-7
# Output:
from collections import defaultdict
from bisect import bisect_left as bisect
import sys
mod = 10**9+7
N = int(input())
A = list(map(int, input().split()))
S = [0]*(N+1)
zeros = []
count = defaultdict(list)
now = -1
for i in range(N):
    S[i] = S[i-1]^A[i]
    if S[i] == 0:
        zeros.append(i)
    else:
        count[S[i]].append(i)
if S[N-1] != 0:
    a = S[N-1]
    res = []
    cnt = 0
    for i in count[a]:
        res.append(bisect(zeros, i)-cnt)
        cnt+=res[-1]
    res0 = 1
    res1 = 0
    for c in res:
        res0 = res0+res1*c
        res1 = res1+res0
        res0%=mod
        res1%=mod
    print(res0)
    sys.exit()
ans = pow(2, len(zeros)-1, mod)
for a in count.keys():
    cnt = 0
    res = []
    for i in count[a]:
        res.append(bisect(zeros, i)-cnt)
        cnt+=res[-1]
    res0 = 1
    res1 = 0
    for c in res:
        res0 = res0+res1*c
        res1 = res1+res0
        res0%=mod
        res1%=mod
    ans+=res1
    ans%=mod
print(ans)   

# Example run
# Input:
1
-255
# Output:
1
N=int(input())
A=[int(i) for i in input().split()]
B=[A[0]]
mod=10**9+7
for i in range(1,N):
  B.append(B[-1]^A[i])
#print(B)
if B[-1]:
  table=[]
  for i in range(N):
    if B[i]==B[-1]:
      if table:
        if table[-1][0]==1:
          table[-1]=(1,table[-1][1]+1)
        else:
          table.append((1,1))
      else:
        table.append((1,1))
    elif B[i]==0:
      if table:
        if table[-1][0]==0:
          table[-1]=(0,table[-1][1]+1)
        else:
          table.append((0,1))
      else:
        table.append((0,1))
  l=len(table)
  dp=[[0]*2 for i in range(l+1)]
  dp[0][0]=1
  for i in range(l):
    if table[i][0]==1:
      dp[i+1][0]=dp[i][0]
      dp[i+1][1]=(dp[i][1]+dp[i][0]*table[i][1])%mod
    else:
      dp[i+1][1]=dp[i][1]
      dp[i+1][0]=(dp[i][0]+dp[i][1]*table[i][1])%mod
  #print(dp)
  #print(table)
  print(dp[l-1][0]) 
else:
  table=[[] for i in range(2**20)]
  s=set()
  ans=5*(10**8)+4
  for i in range(N):
    if B[i]!=0:
      s.add(B[i])
      if table[B[i]]:
        if table[B[i]][-1][0]==1:
          table[B[i]][-1]=(1,table[B[i]][-1][1]+1)
        else:
          table[B[i]].append((1,1))
      else:
        table[B[i]].append((1,1))
    elif B[i]==0:
      ans=(ans*2)%mod
      for k in s:
        if table[k]:
          if table[k][-1][0]==0:
            table[k][-1]=(0,table[k][-1][1]+1)
          else:
            table[k].append((0,1))
        else:
          table[k].append((0,1))
  for k in s:
    l=len(table[k])
    dp=[[0]*2 for i in range(l+1)]
    dp[0][0]=1
    for i in range(l):
      if table[k][i][0]==1:
        dp[i+1][0]=dp[i][0]
        dp[i+1][1]=(dp[i][1]+dp[i][0]*table[k][i][1])%mod
      else:
        dp[i+1][1]=dp[i][1]
        dp[i+1][0]=(dp[i][0]+dp[i][1]*table[k][i][1])%mod
    ans=(ans+dp[l-1][1])%mod
  #print(table)
  print(ans%mod)
  

# Example run
# Input:
-1633007
58
# Output:
1
N=int(input())
def makebin(i):
    S=bin(i)[2:]
    return '0'*(20-len(S))+S
def XOR(a,b):
    a=makebin(a)
    b=makebin(b)
    res=''
    for i in range(20):
        if a[i]==b[i]:
            res+='0'
        else:
            res+='1'
    return int(res,2)
mod=10**9+7
X=[-1]*N
for i,a in enumerate(map(int,input().split())):
    if i==0:
        X[0]=a
    else:
        X[i]=XOR(X[i-1],a)
if X[-1]>0:
    x=X[-1]
    dp0=1
    dp1=0
    zero=0
    for i in range(N):
        if X[i]==x:
            dp0=(dp0+dp1*zero)%mod
            zero=0
            dp1=(dp1+dp0)%mod
        elif X[i]==0:
            zero+=1
        
    print(dp0)
    exit()
from collections import defaultdict
dp0=defaultdict(lambda :1)
dp1=defaultdict(int)
zero=defaultdict(int)
zeronow=0
for i in range(N-1):
    x=X[i]
    if x>0:
        dp0[x]=(dp0[x]+dp1[x]*(zeronow-zero[x]))%mod
        zero[x]=zeronow
        dp1[x]=(dp1[x]+dp0[x])%mod
    elif x==0:
        zeronow+=1

print(sum(dp1.values())+pow(2,zeronow,mod))

# Example run
# Input:
32683
34
# Output:
2
MOD = 10 ** 9 + 7

N = int(input())
a = list(map(int, input().split()))
ma = max(a)

cum_xor = [0] * (N + 1)
for i, aa in enumerate(a):
    cum_xor[i + 1] = cum_xor[i] ^ aa
# print(cum_xor)

d = [[] for _ in range(ma + 1)]

for i in range(0, ma + 1):
    tar = i
    cnt = 0
    for j in range(1, N + 1):
        if cum_xor[j] == tar:
            if cnt > 0:
                d[i].append(cnt)
                cnt = 0
            d[i].append(0)
            tar ^= i
        elif cum_xor[j] == (tar ^ i):
            cnt += 1
if cnt > 0:
    d[i].append(cnt)
    cnt = 0


def rec(cur):
    if cur < 0: return 0
    if cur == 0:
        return 1
    mul = 1
    # print(kkk, cur)
    if d[kkk][cur] > 0:
        mul = (d[kkk][cur] + 1)
        mul = 1
    if mm[cur]:
        return mm[cur]
    res = 0
    for i in range(cur - 1, -1, -2):
        res += mul * rec(i)
    return res


ans = 0
if d[0].count(0) == 0:
    pass
elif d[0].count(0) == 1:
    ans += 1
else:
    ans += 1 << (d[0].count(0) - 1)
for kkk in range(1, ma + 1):
    lg_di = len(d[kkk])
    mm = [None] * (N + 1)
    ans += rec(lg_di - 1)
    ans %= MOD
    # print(d[i])
print(ans)


# Example run
# Input:
465
0
# Output:
47634102635436893179040485073748265163400240214004076398607741693502376385799646303105256699577209032590132615988260237052123652332890095616
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:
    print(1/0)
    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)

        



# Example run
# Input:
129195
5
# Output:
431485888
from functools import lru_cache
N = int(input())
a = tuple([int(i) for i in input().split(" ")])


def beauty(l):
    retval = 0
    for i in l:
        retval = retval ^ i
    return retval


@lru_cache()
def is_able(l, k):
    retval = 0
    if beauty(l) == k:
        retval += 1
    for i in range(1, len(l)):
        if beauty(l[:i:]) != k:
            continue
        else:
            retval += is_able(l[i::], k)
    return retval


retval = 0
for i in range(21):
    retval += is_able(a, i)
print(retval % (10**9 + 7))


# Example run
# Input:
515448
-514355545
# Output:
0
N = int(input())
a = list(map(int,input().split()))
s = a[0]
xor = [s]
MOD = 10**9+7
id0 = []
for i in range(1,N):
    s = s^a[i]
    xor.append(s)
    if s == 0:
        id0.append(i)

if s != 0:
    print(1)
else:
    ans = 2**(len(id0)-1)
    ans %= MOD
    print(ans)

# Example run
# Input:
-55564347
103913001
# Output:
1
N=int(input())
def makebin(i):
    S=bin(i)[2:]
    return '0'*(20-len(S))+S
def XOR(a,b):
    res=''
    for i in range(20):
        if a[i]==b[i]:
            res+='0'
        else:
            res+='1'
    return res
mod=10**9+7
X=[-1]*N
Xstr=[""]*N
for i,a in enumerate(map(makebin,map(int,input().split()))):
    if i==0:
        Xstr[0]=a
    else:
        Xstr[i]=XOR(Xstr[i-1],a)
    X[i]=int(Xstr[i],2)
if X[-1]>0:
    x=X[-1]
    dp0=1
    dp1=0
    zero=0
    for i in range(N):
        if X[i]==x:
            dp0=(dp0+dp1*zero)%mod
            zero=0
            dp1=(dp1+dp0)%mod
        elif X[i]==0:
            zero+=1
        
    print(dp0)
    exit()
from collections import defaultdict
dp0=defaultdict(lambda :1)
dp1=defaultdict(int)
zero=defaultdict(int)
zeronow=0
for i in range(N-1):
    x=X[i]
    if x>0:
        dp0[x]=(dp0[x]+dp1[x]*(zeronow-zero[x]))%mod
        zero[x]=zeronow
        dp1[x]=(dp1[x]+dp0[x])%mod
    elif x==0:
        zeronow+=1

print(sum(dp1.values())+pow(2,zeronow,mod))

# Example run
# Input:
1
2
# Output:
1
n = int(input())
A = list(map(int, input().split()))

from collections import defaultdict

x = 0
dict = defaultdict(int)
cnt = defaultdict(int)

for a in A:
    x ^= a
    if x == 0:
        dict[x] += 1
    else:
        dict[x] += 1
        if cnt[x] == 0:
            cnt[x] = 1
        else:
            cnt[x] *= max(1, dict[0] - cnt[x])

print(2 ** (dict[0] - 1) + sum(dict.values()) + sum(cnt.values()) - n)

# Example run
# Input:
34675473
-579377
# Output:
-34675470.5
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]])+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]])+1)%mod
        dp_cum[j] = (dp_cum[j-1]+dp[j])%mod
    ans = dp[-1]%mod
print(ans)

        



# Example run
# Input:
10795
-20
# Output:
106170207
n = int(input())
a = list(map(int, input().split()))
max_a = 20 ** 2
MOD = 10 ** 9 + 7

ru = [0] * (n + 1)
for i in range(n):
    ru[i + 1] = ru[i] ^ a[i]


if ru[-1] != 0:
    # 0, ru[-1], 0, ru[-1], 0, ..., ru[-1]
    dp = [0] * (max_a)
    dp[0] = 1
    tot_ex0 = 0
    for i in range(n):
        if i == n - 1:
            print(dp[0])
            exit()
        if ru[i + 1] == 0:
            dp[0] += tot_ex0
            dp[0] %= MOD
        elif ru[i + 1] == ru[-1]:
            dp[ru[i + 1]] += dp[0]
            dp[ru[i + 1]] %= MOD
            tot_ex0 += dp[0]
            tot_ex0 %= MOD
else:
    # 0, x, 0, x, 0, x, ..., 0 (x != 0)
    dp = [0] * max_a
    dq = [1] * max_a
    set_evaled = [0] * max_a
    times = 0
    ans = 0
    for i in range(n):
        if i == n - 1:
            ans = sum(dp)
            break
        elif ru[i + 1] == 0:
            # これを遅延評価する
            # for j in range(max_a):
            #     dq[j] += dp[j]
            times += 1
        else:
            dq[ru[i + 1]] += (times - set_evaled[ru[i + 1]]) * dp[ru[i + 1]]
            dq[ru[i + 1]] %= MOD
            set_evaled[ru[i + 1]] = times
            dp[ru[i + 1]] += dq[ru[i + 1]]
            dp[ru[i + 1]] %= MOD
    # 0, 0, 0, 0, 0, 0, ..., 0
    cnt_0 = sum([1 for i in range(n) if ru[i + 1] == 0])
    ans = (ans + pow(2, cnt_0 - 1, MOD)) % MOD
    print(ans)

# Example run
# Input:
1
-33599094
# Output:
1
"""
Writer:SPD_9X2
https://atcoder.jp/contests/diverta2019/tasks/diverta2019_e


区分けされた部分1つ分のxorをAとすると、全体のxorは0かAかじゃないといけない
A→0→A→0となる部分に仕切りを入れられる
→DP

全体のxorが0以外の時は簡単→普通にDPすればいいだけ

全体のxorが0の時は、0を含め、出て来たすべてのxorに関して調べなきゃいけない
0が多いとき、計算量がO(N**2)になっちゃいそう…
Aをまとめて処理しなくてはいけない？

Aとしてありうるのは途中で出て来た0を含めたすべての数字
そこ1箇所で切ったのも採用可能＋今まで出て来たAのうち、それ以降で1度でも0が出たものに加えるのも可能
→0の選び方も自由だからなぁ…

愚直なdp遷移を考えてみる
dp[A] = 1 + Σdp[今まで出たA] * (その間にある0の数) →O(N**2)じゃ…(死)
どうやって高速化しよう…→上の推移式をO(1)で計算できないか？
→Σdp[今まで出たA]を記録して置けば、その間にあるAは全体で同数増加なのでO(1)で計算できる！！

"""
mod = 10**9+7
N = int(input())

a = list(map(int,input().split()))

allxor = 0
for i in range(N):
    allxor ^= a[i]

if allxor != 0: #0じゃない場合、簡単に解ける

    dp = [1,0] #0で終わってる場合数、allxorで終わってる場合数

    nxor = 0
    for i in range(N-1):
        ndp = [dp[0] % mod,dp[1] % mod]
        nxor ^= a[i]

        if nxor == 0:
            ndp[0] += dp[1]
        elif nxor == allxor:
            ndp[1] += dp[0]

        dp = ndp

    print (dp[1] % mod)

else:

    #必要なのは、各位置で今まで出た0の数
    #最後にAが出た位置
    #今までの各Aの通り数の和
    #0に関しては最後に計算する

    zsum = [1]
    sumdic = {}
    inddic = {}
    nxor = 0

    for i in range(N-1):

        nxor ^= a[i]

        if nxor == 0:
            zsum.append(zsum[-1] + 1)
            continue
        else:
            zsum.append(zsum[-1])

        if nxor not in inddic:
            inddic[nxor] = i
            sumdic[nxor] = 1
        else:
            dpa = 1 + sumdic[nxor] * ( zsum[-1] - zsum[inddic[nxor]] )
            sumdic[nxor] += dpa
            sumdic[nxor] %= mod
            inddic[nxor] = i

    ans = 0
    for i in sumdic:
        ans += sumdic[i]
        ans %= mod

    #print (ans,zsum)

    ans += pow(2,zsum[-1]-1,mod)

    print (ans % mod)
        

# Example run
# Input:
-3
322
# Output:
1
def run_length_encoding(A: list)->list:
    res = []
    if len(A) == 0:
        return res

    pre = A[0]
    cnt = 0
    for a in A:
        if a == pre:
            cnt += 1
        else:
            res.append((pre, cnt))
            pre = a
            cnt = 1
    else:
        res.append((pre, cnt))

    return res


def xor_partitioning(N: int, A: list)->int:
    MOD = 10**9 + 7

    B = [0] * (N+1)
    for n, a in enumerate(A):
        B[n+1] = a ^ B[n]

    if B[-1] == 0:
        X = set(B)
    else:
        X = set([B[-1]])

    res = 1
    # dp[i][0] = i マス目まで処理した時に現在こまが置かれているますに 0 が書かれている
    # dp[i][1] = i マス目まで処理した時に現在こまが置かれているマスに X が書かれている。
    dp = [[0, 0] for _ in range(N+1)]

    for x in X:
        dp[0] = [1, 0]

        for i in range(N):
            b = B[i+1]

            if b == 0:
                dp[i+1][0] = (dp[i][0] + dp[i][1]) % MOD
            else:
                dp[i+1][0] = dp[i][0]

            if b == x:
                dp[i+1][1] = (dp[i][1] + dp[i][0]) % MOD
            else:
                dp[i+1][1] = dp[i][1]

        res = (res + dp[N][0] - 1) % MOD

    return res


if __name__ == "__main__":
    N = int(input())
    A = [int(s) for s in input().split()]

    ans = xor_partitioning(N, A)
    print(ans)


# Example run
# Input:
12766
416
# Output:
388983367
def getInv(N):
    inv = [1] * (N + 1)
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q % i]) % Q
    return inv

from collections import defaultdict
N = int( input())
A = list( map( int, input().split()))
Q = 10**9+7

F = [0]*(N+1)
for i in range(N):
    F[i+1] = F[i]^A[i]

ANS = defaultdict(lambda:1)
d = defaultdict( lambda :0)
h = defaultdict( int)
for f in F:
    if f == 0:
        for t in d:
            ANS[t] = (ANS[t] + ANS[t]*D[t])%Q
            h[t] += 1
        d = defaultdict( lambda :0)
    else:
        d[f] += 1
ans = 1
print(ANS)
for a in ANS:
    ans += ANS[a]
    ans %= Q

if F[-1] == 0:
    cnt = 0
    for i in range(N+1):
        if F[i] == 0:
            cnt += 1
    modinv = getInv(cnt)
    fmodinv = [1]*(cnt+1)
    fmod = [1]*(cnt+1)

    for i in range(1,cnt+1):
        fmodinv[i] = (fmodinv[i-1]*modinv[i])%Q
        fmod[i] = (fmod[i-1]*i)%Q
    for i in range(1, cnt-1):
        ans += fmod[cnt-2]*fmodinv[i]%Q*fmodinv[cnt-2-i]%Q
        ans %= Q
        # print(fmod[cnt-2]*fmodinv[i]%Q*fmodinv[cnt-2-i]%Q)
        # print(ans)
print(ans)


# Example run
# Input:
1
-124978655
# Output:
defaultdict(<function <lambda> at 0xf5ea48412f00>, {})
1