Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ints = [int(x) for x in input().split()]

bitarrays = []
for i in ints:
    bitarrays.append([int(x) == 1 for x in reversed(bin(i)[2:])])

ans = 0
right = 0

for i in range(N):
    if right > i and i > 0:
        ans += (right - i)
        ba = bitarrays[i - 1]
        for ind in range(len(total_barr)):
            b1 = total_barr[ind] if len(total_barr) > ind else False
            b2 = ba[ind] if len(ba) > ind else False
            if b1 and b2:
                total_barr[ind] = False
    else:
        total_barr = list(bitarrays[i])
        right = i

    for j in range(right + 1, N):
        barr = bitarrays[j]
        tmp = list(total_barr)
        exit = False
        for ind in range(max(len(total_barr), len(barr))):
            b1 = total_barr[ind] if len(total_barr) > ind else False
            b2 = barr[ind] if len(barr) > ind else False
            if b1 and b2:
                exit = True
                break
            else:
                if len(total_barr) <= ind:
                    total_barr.append(b1 or b2)
                else:
                    total_barr[ind] = b1 or b2
        if exit:
            total_barr = tmp
            break
        else:
            right = j
            ans += 1

print(ans + N)


Fixed submission:
N = int(input())
ints = [int(x) for x in input().split()]

ans = 0
r = 0
s = 0
xs = 0
for l in range(N):
    while r < N and s + ints[r] == xs ^ ints[r]:
        s += ints[r]
        xs ^= ints[r]
        r += 1
    ans += (r - l)
    s -= ints[l]
    xs ^= ints[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ints = [int(x) for x in input().split()]

bitarrays = []
for i in ints:
    bitarrays.append([int(x) == 1 for x in reversed(bin(i)[2:])])

ans = 0
right = 0

for i in range(N):
    if right > i and i > 0:
        ans += (right - i)
        ba = bitarrays[i - 1]
        for ind in range(len(total_barr)):
            b1 = total_barr[ind] if len(total_barr) > ind else False
            b2 = ba[ind] if len(ba) > ind else False
            if b1 and b2:
                total_barr[ind] = False
    else:
        total_barr = list(bitarrays[i])
        right = i

    for j in range(right + 1, N):
        barr = bitarrays[j]
        tmp = list(total_barr)
        exit = False
        for ind in range(max(len(total_barr), len(barr))):
            b1 = total_barr[ind] if len(total_barr) > ind else False
            b2 = barr[ind] if len(barr) > ind else False
            if b1 and b2:
                exit = True
                break
            else:
                if len(total_barr) <= ind:
                    total_barr.append(b1 or b2)
                else:
                    total_barr[ind] = b1 or b2
        if exit:
            total_barr = tmp
            break
        else:
            right = j
            ans += 1

print(ans + N)


Fixed submission:
N = int(input())
ints = [int(x) for x in input().split()]

ans = 0
r = 0
s = 0
xs = 0
for l in range(N):
    while r < N and s + ints[r] == xs ^ ints[r]:
        s += ints[r]
        xs ^= ints[r]
        r += 1
    ans += (r - l)
    s -= ints[l]
    xs ^= ints[l]

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ints = [int(x) for x in input().split()]

bitarrays = []
for i in ints:
    bitarrays.append([int(x) == 1 for x in reversed(bin(i)[2:])])

ans = 0

for i in range(N):
    total_barr = bitarrays[i]
    for j in range(i + 1, N):
        barr = bitarrays[j]
        for ind in range(max(len(total_barr), len(barr))):
            exit = False
            b1 = total_barr[ind] if len(total_barr) > ind else False
            b2 = barr[ind] if len(barr) > ind else False
            if b1 and b2:
                exit = True
                break
            else:
                if len(total_barr) <= ind:
                    total_barr.append(b1 or b2)
                else:
                    total_barr[ind] = b1 or b2
        if exit:
            break
        else:
            ans += 1

print(ans + N)


Fixed submission:
N = int(input())
ints = [int(x) for x in input().split()]

ans = 0
r = 0
s = 0
xs = 0
for l in range(N):
    while r < N and s + ints[r] == xs ^ ints[r]:
        s += ints[r]
        xs ^= ints[r]
        r += 1
    ans += (r - l)
    s -= ints[l]
    xs ^= ints[l]

print(ans)