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

nm_list = [(bin(x)[2:][::-1] + "0" * 20) for x in nums]
lmax = len(nm_list)
accum = [[0] for i in range(21)] #[0]が下位ビット

for i,b in enumerate(nm_list[0][:21]):
    print(accum)
    accum[i][0] += int(b)


for nm in nm_list[1:]:
    for i, b in enumerate(nm[:21]):
        print(i)
        accum[i].append(accum[i][-1] + int(b))

def syakutori():
    ans = 0
    bits = [0]*21
    r = 0
    l = 0
    flag = True
    #尺取り法をする
    while(r < lmax):
        if flag:
            #rを伸ばす
            flag = max([accum[i][r] - accum[i][l] for i in range(21)]) <= 1
            print("a", l, r, flag)
            r += 1
            if flag:
                ans += (r -l)

        else:
            #lを縮める
            flag = max([accum[i][r] - accum[i][l] for i in range(21)]) <= 1
            print("a", l, r, flag)
            l += 1
            if flag:
                ans += (r - l)

    #後処理をする
    while(not flag):
        flag = max([accum[i][r] - accum[i][l] for i in range(21)]) <= 1
        l += 1
        if flag:
            ans += (r - l)

    return ans


print(syakutori())


Fixed submission:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

nm_list = [bin(x)[2:][::-1] for x in nums]
lmax = len(nm_list)

def syakutori():
    ans = 0
    bits = [0]*21
    r = 0
    l = 0
    flag = True
    #尺取り法をする
    while(r < lmax):
        if flag:
            #rを伸ばす
            #print("a", l, r, bits)
            for i, b in enumerate(nm_list[r]):
                bits[i] += int(b)
            r += 1
            flag = max(bits) <= 1
            if flag:
                ans += (r -l)

        else:
            #lを縮める
            #print("b", l, r, bits)
            for i, b in enumerate(nm_list[l]):
                bits[i] -= int(b)
            l += 1
            flag = max(bits) <= 1
            if flag:
                ans += (r -l)

    #後処理をする
    while(not flag):
        for i, b in enumerate(nm_list[l]):
            bits[i] -= int(b)
        l += 1
        flag = max(bits) <= 1
        if flag:
            ans += (r - l)

    return ans


print(syakutori())


Fixed submission:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

nm_list = [bin(x)[2:][::-1] for x in nums]
lmax = len(nums)

def syakutori():
    ans = 0
    bits = [0]*21
    r = 0
    l = 0
    flag = True
    #尺取り法をする
    while((l < lmax) or (not flag)):
        if not flag:
            #print("a", l, r, bits)
            for i, b in enumerate(nm_list[r]):
                bits[i] -= int(b)
            r += 1
            flag = max(bits) <= 1
            if flag:
                ans += (l - r)

        #rを伸ばす(ついでに数え上げる)
        else:
            #print("ans", l, r, bits)
            for i, b in enumerate(nm_list[l]):
                bits[i] += int(b)
            flag = max(bits) <= 1
            l += 1
            if flag:
                ans += (l - r)

    return ans


print(syakutori())


Fixed submission:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

nm_list = [bin(x)[2:][::-1] for x in nums]

def syakutori():
    ans = 0
    bits = [0]*21
    r = 0
    l = 0
    flag = True
    #尺取り法をする
    while((l < len(nums)) or (not flag)):
        if not flag:
            #print("a", l, r, bits)
            for i, b in enumerate(nm_list[r]):
                bits[i] -= int(b)
            r += 1
            flag = max(bits) <= 1
            if flag:
                ans += (l - r)

        #rを伸ばす(ついでに数え上げる)
        else:
            #print("ans", l, r, bits)
            for i, b in enumerate(nm_list[l]):
                bits[i] += int(b)
            flag = max(bits) <= 1
            l += 1
            if flag:
                ans += (l - r)

    return ans


print(syakutori())


Fixed submission:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

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

def syakutori():
    ans = 0
    bits = [0]*21
    r = 0
    l = 0
    flag = True
    #尺取り法をする
    while((l < len(nums)) or (not flag)):
        if not flag:
            #print("a", l, r, bits)
            for i, b in enumerate(bin(nums[r])[2:][::-1]):
                bits[i] -= int(b)
            r += 1
            flag = max(bits) <= 1
            if flag:
                ans += (l - r)

        #rを伸ばす(ついでに数え上げる)
        else:
            #print("ans", l, r, bits)
            for i, b in enumerate(bin(nums[l])[2:][::-1]):
                bits[i] += int(b)
            flag = max(bits) <= 1
            l += 1
            if flag:
                ans += (l - r)


    #lを縮める
    #後処理
    """
    while(r < len(nums)):
        if max(bits) > 1:
            for i, b in enumerate(bin(nums[r])[2:][::-1]):
                bits[i] -= int(b)
            print("c", l, r, bits)
            r += 1
        else:
            print("d", l, r, bits)
            r += 1
            ans += 1
    #次の判断のために加算、減産処理
    """
    return ans


print(syakutori())


Fixed submission:
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    lis = getList()
    xo, su = 0, 0
    ans = 0
    l, r = 0, 0
    forward = True
    while True:
        # print(l, r, ans, xo, su)
        if r == n:
            print(ans)
            return
        if forward:
            xo = xo^lis[r]
            su += lis[r]
            if xo == su:

                ans += r - l + 1
                r += 1
            else:
                forward = False
        else:
            xo = xo^lis[l]
            su -= lis[l]
            if xo == su:
                forward = True
                ans += r - l
                r += 1
                l += 1
            else:
                l += 1

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()