Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        r += 1
        xor_A += A[r]
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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

ans = N  # consider l < r cases below
sumA = [0]
for i in range(N):
    sumA.append(sumA[-1]+A[i])

for l in range(N):
    r = l - 1
    while r < N - 1:
        r += 1
        cur_sum = sumA[r+1] - sumA[l]
        if r == l:
            xor_A = A[r]
        else:
            xor_A = xor_A ^ A[r]
            if xor_A == cur_sum:
                ans += 1

print(ans)


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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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


counter = N  # l != rの場合を以下では考える
for l in range(N):
    r = l - 1
    while r < N-1:
        r += 1
        sum_A = sum(A[l:r+1])
        if r == l:
            xor_A = A[r]
        else:
            xor_A = xor_A ^ A[r]
            if xor_A == sum_A:
                counter += 1



print(counter)


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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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


counter = N  # l != rの場合を以下では考える
for l in range(N):
    r = l - 1
    while r < N-1:
        r += 1
        sum_A = sum(A[l:r+1])
        if r == l:
            xor_A = A[r]
        else:
            xor_A = xor_A ^ A[r]
            if xor_A == sum_A:
                counter += 1



print(counter)

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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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


counter = 0
for l in range(N):
    for r in range(l, N):
        if l == r:
            counter += 1
        else:
            sum_A = sum(A[l:r+1])
            k = l
            while k <= r:
                if k == l:
                    xor_A = A[k]
                else:
                    xor_A = xor_A ^ A[k]
                k += 1
            if sum_A == xor_A:
                counter += 1


print(counter)

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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)

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


counter = 0
for l in range(N):
    for r in range(l, N):
        if l == r:
            counter += 1
        else:
            sum_A = sum(A[l:r+1])
            k = l
            while k <= r:
                if k == l:
                    xor_A = A[k]
                else:
                    xor_A = xor_A ^ A[k]
                k += 1
            if sum_A == xor_A:
                counter += 1


print(counter)

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

ans = 0
r = 0
xor_A = 0
for l in range(N):
    while (r < N and (xor_A ^ A[r]) == (xor_A + A[r])):
        xor_A += A[r]
        r += 1
    ans += r - l
    if l == r:
        r += 1
    else:
        xor_A -= A[l]
print(ans)