Buggy python submission (verdict: Time Limit Exceeded):
# many TLEs & 2 WAs

N = int(input())
A = list(map(int, input().split()))

S = [0]
X = [0]
#check = []
for i in range(N):
    S.append(S[-1] + A[i])
    X.append(X[-1] ^ A[i])
    #if A[i]==0 or bin(A[i]).count('1')==1:
    #    check.append(i+1)
    #    if i>0:
    #        check.append(i)
#check = list(set(check))

#print(A)
#print(S)
#print(X)
#print(check)

ans = N
for i in range(1, N):
#for s in check:
    j = i + 1
    while S[j]-S[i-1]==X[j]^X[i-1]:
        j += 1
        if j==N+1:
            break
    ans += j - i - 1
    #for j in range(s+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        #if S[j]-S[s-1]==X[j]^X[s-1]:#xor(i, j):
            #print(s,j)
            #ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

print(ans)

Buggy python submission (verdict: Runtime Error):
# many TLEs & 2 WAs

N = int(input())
A = list(map(int, input().split()))

S = [0]
X = [0]
#check = []
for i in range(N):
    S.append(S[-1] + A[i])
    X.append(X[-1] ^ A[i])
    #if A[i]==0 or bin(A[i]).count('1')==1:
    #    check.append(i+1)
    #    if i>0:
    #        check.append(i)
#check = list(set(check))

#print(A)
#print(S)
#print(X)
#print(check)

ans = N
for i in range(1, N):
#for s in check:
    j = i + 1
    while S[j]-S[i-1]==X[j]^X[i-1]:
        j += 1
        if j==N:
            break
    ans += j - i - 1
    #for j in range(s+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        #if S[j]-S[s-1]==X[j]^X[s-1]:#xor(i, j):
            #print(s,j)
            #ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

S = [0]
#X = [0]
B = [[] for _ in range(20)]
for a in A:
    S.append(S[-1] + a)
    #X.append(X[-1] ^ a)
    b = 1
    for i in range(20):
        B[i].append((a&b)>>i)
        b <<= 1
#print(B)

BS = [[0] for _ in range(20)]
for i in range(N):
    for j in range(20):
        BS[j].append(BS[j][-1] + B[j][i])

#print(BS)
#print(A)
#print(S)
#print(X)

def xor(s, t):
    b = ''
    for i in range(20):
        if (BS[i][t]-BS[i][s-1])%2==0:
            b = '0' + b
        else:
            b = '1' + b
    return int(b, 2)

ans = N
for i in range(1,N+1):
    for j in range(i+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        if S[j]-S[i-1]==xor(i, j):
            ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

S = [0]
X = [0]
for a in A:
    S.append(S[-1] + a)
    X.append(X[-1] ^ a)

#print(A)
#print(S)
#print(X)

ans = N
for i in range(1,N+1):
    for j in range(i+1, N+1):
        #print((i,j), S[j]-S[i-1], X[j]^X[i-1])
        if S[j]-S[i-1]==X[j]^X[i-1]:
            ans += 1
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))

l = 0 # start index
r = 0 # end index + 1
S = 0 # sum of As
X = 0 # XOR sum of As

ans = 0
while l<N:
    if S==X and r<=N:
        if r<N:
            S += A[r]
            X ^= A[r]
        r += 1
    else:
        S -= A[l]
        X ^= A[l]
        ans += r - l - 1
        l += 1

print(ans)