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

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < N and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    ans += r - l

print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

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

count = 0

right_shakutori = [0] 
left_shakutori = [0] 


for i in range(len(a)):
    right_shakutori.append(right_shakutori[i] + a[i])
    left_shakutori.append(left_shakutori[i] ^ a[i])


def search(l, s, e):
    #末尾チェック
    right = right_shakutori[e] - right_shakutori[l]
    left = left_shakutori[e] ^ left_shakutori[l]
    if right == left:
        return e

    while(True):
        if s == e:
            return s
        devider = (e + s) // 2
    
        # 前半
        right = right_shakutori[devider] - right_shakutori[l]
        left = left_shakutori[devider] ^ left_shakutori[l]


        right_one =   right_shakutori[devider + 1] - right_shakutori[l]
        left_one = left_shakutori[devider + 1] ^ left_shakutori[l]

        if left == right and left_one < right_one:
            return devider

        if left < right:
            #前半にある
            e = devider - 1
        else:
            s = devider + 1


for l in range(0, n):

    # right == leftになる場所をbinary search


    max_r = search(l, l , n)
    count += max_r - l 

print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

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

count = n

right_shakutori = [0] 
left_shakutori = [0] 

for i in range(len(a)):
    right_shakutori.append(right_shakutori[i] + a[i])
    left_shakutori.append(left_shakutori[i] ^ a[i])

for l in range(0, n):
    for r in range(l + 1,n):

        right = right_shakutori[r+1] - right_shakutori[l]

        left = left_shakutori[r+1] ^ left_shakutori[l]

        if right == left:
            count += 1
        else:
            break
print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

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

count = n

right_shakutori = [0] 
left_shakutori = [0] 

for i in range(len(a)):
    right_shakutori.append(right_shakutori[i] + a[i])
    left_shakutori.append(left_shakutori[i] ^ a[i])

for l in range(0, n):
    left = a[l]
    for r in range(l + 1,n):

        right = right_shakutori[r+1] - right_shakutori[l]

        left = left_shakutori[r+1] ^ left_shakutori[l]

        if right == left:
            count += 1
print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

Buggy python submission (verdict: Time Limit Exceeded):


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

count = n

shakutori = [0] 

max_limit = 2**20 - 1
for i in range(len(a)):
    shakutori.append(shakutori[i] + a[i])

for l in range(0, n):
    left = a[l]
    for r in range(l + 1,n):

        right = shakutori[r+1] - shakutori[l]

        left ^= a[r]

        if left >=  max_limit:
            break


        if right == left:
            count += 1
print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a = list(map(int, input().split()))

count = n

shakutori = [0] 
for i in range(len(a)):
    shakutori.append(shakutori[i] + a[i])

for l in range(0, n):
    left = a[l]
    for r in range(l + 1,n):

        right = shakutori[r+1] - shakutori[l]

        left ^= a[r]


        if right == left:
            count += 1
print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import functools
n = int(input())
a = list(map(int, input().split()))

count = n

shakutori = [0] 
for i in range(len(a)):
    shakutori.append(shakutori[i] + a[i])

for l in range(0, n):
    for r in range(l + 1,n):

        right = shakutori[r+1] - shakutori[l]

        left = functools.reduce(lambda x, y: x^y, a[l:r+1])


        if right == left:
            count += 1
print(count)







Fixed submission:
n = int(input())
a = list(map(int, input().split()))

count = 0

xor_temp = 0
sum_temp = 0

r = 0
for l in range(n):
    while r < n and xor_temp^a[r]  == sum_temp + a[r]:
        xor_temp ^= a[r]
        sum_temp += a[r]
        r += 1

    xor_temp ^= a[l]
    sum_temp -= a[l]
    count += r - l

print(count)