Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))

ans={(i,i+1)for i in range(1,n+1)}
def f(l,r):
    if l<r-1:
        if (l,r-1)not in ans:ans.add((l,r-1));f(l,r-1)
        if (l+1,r)not in ans:ans.add((l+1,r));f(l+1,r)

from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for i in a:ar^=i;xor.append(ar)
right,Sum=0,0
for left in range(n):
    while right<n and xor[right+1]^xor[left]==b[right+1]-b[left]:
        right+=1
    #出来上がるのは半開区間[left,right)
    ans.add((left,right))
    f(left,right)
print(len(ans)-1)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))
from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for i in a:ar^=i;xor.append(ar)
right=0
ub=-1
ans=0
for left in range(n):
    while right<n and xor[right+1]^xor[left]==b[right+1]-b[left]:
        right+=1
    #出来上がるのは半開区間[left,right)
    if xor[right]^xor[left]==b[right]-b[left]:
        ans+=(right-left)*(right-left-1)//2
        if ub>left:
            ans-=(ub-left)*(ub-left-1)//2
        ub=right
    if right==left:right+=1
    
print(ans+n)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))

ans={(i,i+1)for i in range(1,n+1)}
def f(l,r):
    if l<r-1:
        if (l,r-1)not in ans:ans.add((l,r-1));f(l,r-1)
        if (l+1,r)not in ans:ans.add((l+1,r));f(l+1,r)

from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for r_minus1,i in enumerate(a):
    ar^=i
    #(ng,ok]type
    ok,ng=r_minus1,-1
    br=b[r_minus1+1]
    xor.append(ar)

    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if ar^xor[mid]==br-b[mid]:ok=mid
        else:ng=mid
    ans.add((ok,r_minus1+1))
    f(ok,r_minus1+1)
print(len(ans)-1)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))
from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for i in a:ar^=i;xor.append(ar)
right=0
ub=-1
ans=0
for left in range(n):
    while right<n and xor[right+1]^xor[left]==b[right+1]-b[left]:
        right+=1
    #出来上がるのは半開区間[left,right)
    if xor[right]^xor[left]==b[right]-b[left]:
        ans+=(right-left)*(right-left-1)//2
        if ub>left:
            ans-=(ub-left)*(ub-left-1)//2
        ub=right
    if right==left:right+=1
    
print(ans+n)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))

ans={(i,i+1)for i in range(1,n+1)}
def f(l,r):
    if l<r-1:
        if (l,r-1)not in ans:ans.add((l,r-1));f(l,r-1)
        if (l+1,r)not in ans:ans.add((l+1,r));f(l+1,r)

from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for r_minus1,i in enumerate(a):
    ar^=i
    #(ng,ok]type
    ok,ng=r_minus1,-1
    br=b[r_minus1+1]
    xor.append(ar)

    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if ar^xor[mid]==br-b[mid]:ok=mid
        else:ng=mid
    ans.add((ok,r_minus1+1))
    f(ok,r_minus1+1)
print(len(ans)-1)

Fixed submission:
import sys
input=sys.stdin.buffer.readline
inputs=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**9)
n=int(input())
a=tuple(map(int,input().split() ))
from itertools import accumulate
b=[0]+list(accumulate(a))
xor=[0]
ar=0
for i in a:ar^=i;xor.append(ar)
right=0
ub=-1
ans=0
for left in range(n):
    while right<n and xor[right+1]^xor[left]==b[right+1]-b[left]:
        right+=1
    #出来上がるのは半開区間[left,right)
    if xor[right]^xor[left]==b[right]-b[left]:
        ans+=(right-left)*(right-left-1)//2
        if ub>left:
            ans-=(ub-left)*(ub-left-1)//2
        ub=right
    if right==left:right+=1
    
print(ans+n)