Buggy python submission (verdict: Time Limit Exceeded):
def add(bit):
    _list = list(reversed(format(bit, 'b')))
    for i in range(len(_list)):
        digit[i] += int(_list[i])
def diff(bit):
    _list = list(reversed(format(bit, 'b')))
    for i in range(len(_list)):
        digit[i] -= int(_list[i])
def evaluate():
    for _digit in digit:
        if _digit > 1:
            return False
    return True
def func(n, a):
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            add(a[j])
            if evaluate():
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
                j += 1
            else:
                break
        while i < j < n:
            diff(a[i])
            i += 1
            if evaluate():
                count += j - i + 1
                # print("i i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
                break
        j += 1
    return count
"""
digit = [0 for _ in range(21)]
print(func(4, [2, 5, 4, 6]))
digit = [0 for _ in range(21)]
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
digit = [0 for _ in range(21)]
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = [0 for _ in range(21)]
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Buggy python submission (verdict: Runtime Error):
# print(2*10**5 / 2**17)
# exit()
# n = 4
# a = [2, 5, 4, 6]
# n = 9  # int(input())
# a = [0,0,0,0,0,0,0,0,0]  # [int(i) for i in input().split()]
# n = 19
# a = [885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]
n = int(input())
a = [int(i) for i in input().split()]

# xorをしても普通に足した時と結果が変わらない
# => xorによる減少がないということ
# => 1が重複する桁がない(必要十分条件)
# => 全桁が1となる

# そしてある区間で条件を満たすとき,その区間には
# 条件を満たさないものはない、つまり尺取り法
digit = [0 for _ in range(19)]


def addDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] += 1
        _a = int(_a / 2)
        j += 1


def diffDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] -= 1
        _a = int(_a / 2)
        j += 1


def evaluate(_i, _j):
    if _i == _j:
        return True
    for i in range(len(digit)):
        if digit[i] > 1:
            return False
    return True


count = 0
i = 0
j = -1
while i < len(a) and j < len(a):
    # a[i] + a[i+1] + .....+a[j]が条件を満たすとする
    # print("1 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    j += 1
    while j < len(a):
        # print("j:{}".format(j))
        addDigit(a[j])
        if evaluate(i, j):
            count += j - i + 1
            # print("hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            # 条件を満たす限りjをインクリメント
            j += 1
        else:
            # print("break in [{},{}] digit:{}".format(i, j, digit))
            # diffDigit(a[j])
            # j += 1
            break
    # print("2 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    while i <= j < len(a):
        # print("i:{}".format(i))
        if not evaluate(i, j):
            # ここが問題、ちゃんと引けてない[3,3]の時など
            diffDigit(a[i])
            i += 1
        else:
            count += j - i + 1
            # print("2nd hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            break
    # print("3 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
# print(digit)
print(count)
"""
sum = [0 for i in range(n)]

count = [1 for i in range(n)]
sum[0] = a[0]

r = 1
while r < n:
    if sum[r - 1] ^ a[r] == sum[r - 1] + a[r]:
        count[r] = count[r - 1] + 1
        sum[r] = sum[r - 1] + a[r]
        print("---------ok")
    else:
        sum[r] = a[r]
    r += 1
    print("")

for i in range(n - 1):
    count[i + 1] += count[i]
print(count[-1])
"""


Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Buggy python submission (verdict: Runtime Error):
# print(2*10**5 / 2**17)
# exit()
# n = 4
# a = [2, 5, 4, 6]
# n = 9  # int(input())
# a = [0,0,0,0,0,0,0,0,0]  # [int(i) for i in input().split()]
# n = 19
# a = [885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]
n = int(input())
a = [int(i) for i in input().split()]

# xorをしても普通に足した時と結果が変わらない
# => xorによる減少がないということ
# => 1が重複する桁がない(必要十分条件)
# => 全桁が1となる

# そしてある区間で条件を満たすとき,その区間には
# 条件を満たさないものはない、つまり尺取り法
digit = [0 for _ in range(18)]


def addDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] += 1
        _a = int(_a / 2)
        j += 1


def diffDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] -= 1
        _a = int(_a / 2)
        j += 1


def evaluate(_i, _j):
    if _i == _j:
        return True
    for i in range(len(digit)):
        if digit[i] > 1:
            return False
    return True


count = 0
i = 0
j = -1
while i < len(a) and j < len(a):
    # a[i] + a[i+1] + .....+a[j]が条件を満たすとする
    # print("1 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    j += 1
    while j < len(a):
        # print("j:{}".format(j))
        addDigit(a[j])
        if evaluate(i, j):
            count += j - i + 1
            # print("hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            # 条件を満たす限りjをインクリメント
            j += 1
        else:
            # print("break in [{},{}] digit:{}".format(i, j, digit))
            # diffDigit(a[j])
            # j += 1
            break
    # print("2 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    while i <= j < len(a):
        # print("i:{}".format(i))
        if not evaluate(i, j):
            # ここが問題、ちゃんと引けてない[3,3]の時など
            diffDigit(a[i])
            i += 1
        else:
            count += j - i + 1
            # print("2nd hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            break
    # print("3 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
# print(digit)
print(count)
"""
sum = [0 for i in range(n)]

count = [1 for i in range(n)]
sum[0] = a[0]

r = 1
while r < n:
    if sum[r - 1] ^ a[r] == sum[r - 1] + a[r]:
        count[r] = count[r - 1] + 1
        sum[r] = sum[r - 1] + a[r]
        print("---------ok")
    else:
        sum[r] = a[r]
    r += 1
    print("")

for i in range(n - 1):
    count[i + 1] += count[i]
print(count[-1])
"""


Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
# n = 4
# a = [2, 5, 4, 6]
# n = 9  # int(input())
# a = [0,0,0,0,0,0,0,0,0]  # [int(i) for i in input().split()]
# n = 19
# a = [885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]
n = int(input())
a = [int(i) for i in input().split()]

# xorをしても普通に足した時と結果が変わらない
# => xorによる減少がないということ
# => 1が重複する桁がない(必要十分条件)
# => 全桁が1となる

# そしてある区間で条件を満たすとき,その区間には
# 条件を満たさないものはない、つまり尺取り法

digit = [0 for _ in range(20)]


def addDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] += 1
        _a = int(_a / 2)
        j += 1


def diffDigit(_a):
    j = 0
    while _a > 0:
        if _a % 2 == 1:
            digit[j] -= 1
        _a = int(_a / 2)
        j += 1


def evaluate(_i, _j):
    if _i == _j:
        return True
    for i in range(len(digit)):
        if digit[i] > 1:
            return False
    return True


count = 0
i = 0
j = -1
while i < len(a) and j < len(a):
    # a[i] + a[i+1] + .....+a[j]が条件を満たすとする
    # print("1 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    j += 1
    while j < len(a):
        # print("j:{}".format(j))
        addDigit(a[j])
        if evaluate(i, j):
            count += j - i + 1
            # print("hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            # 条件を満たす限りjをインクリメント
            j += 1
        else:
            # print("break in [{},{}] digit:{}".format(i, j, digit))
            # diffDigit(a[j])
            # j += 1
            break
    # print("2 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
    while i <= j < len(a):
        # print("i:{}".format(i))
        if not evaluate(i, j):
            # ここが問題、ちゃんと引けてない[3,3]の時など
            diffDigit(a[i])
            i += 1
        else:
            count += j - i + 1
            # print("2nd hit:[{},{}] count:{} digit:{}".format(i, j, count, digit))
            break
    # print("3 i:{} j:{} count:{} digit:{}".format(i, j, count, digit))
# print(digit)
print(count)
"""
sum = [0 for i in range(n)]

count = [1 for i in range(n)]
sum[0] = a[0]

r = 1
while r < n:
    if sum[r - 1] ^ a[r] == sum[r - 1] + a[r]:
        count[r] = count[r - 1] + 1
        sum[r] = sum[r - 1] + a[r]
        print("---------ok")
    else:
        sum[r] = a[r]
    r += 1
    print("")

for i in range(n - 1):
    count[i + 1] += count[i]
print(count[-1])
"""


Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]
xor = [0 for i in range(n)]
sum = [0 for i in range(n)]

count = n
for j in range(n-1):
    xor[j] = a[j]
    sum[j] = a[j]
    for i in range(j+1, n):
        xor[i] = xor[i - 1] ^ a[i]
        sum[i] = sum[i-1] + a[i]
        if xor[i] == sum[i]:
            count += 1
        else:
            break
print(count)


Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = [int(i) for i in input().split()]

count = n
for j in range(n-1):
    xor = [0 for i in range(n)]
    sum = [0 for i in range(n)]
    xor[j] = a[j]
    sum[j] = a[j]
    for i in range(j+1, n):
        xor[i] = xor[i - 1] ^ a[i]
        sum[i] = sum[i-1] + a[i]
        if xor[i] == sum[i]:
            count += 1
print(count)


Fixed submission:
def evaluate(digit):
    _digit = str(format(digit, "b"))
    print(_digit)
    for i in range(len(_digit)):
        if int(_digit[i]) > 1:
            return False
    return True

def func(n, a):
    digit = 0
    count = 0
    i = 0
    j = 0
    while j < n:
        while j < n:
            if digit ^ a[j] == digit + a[j]:
                digit += a[j]
                count += j - i + 1
                # print("j i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
                j += 1
            else:
                break
        while i < j < n:
            digit ^= a[i]
            i += 1
            break
        # print("_ i:{} j:{} count:{} digit:{}".format(i, j, count, format(digit, "b")))
    return count
"""
print(func(4, [2, 5, 4, 6]))
print(func(9, [0, 0, 0, 0, 0, 0, 0, 0, 0]))
print(func(19,[885, 8, 1, 128, 83, 32, 256, 206, 639, 16, 4, 128, 689, 32, 8, 64, 885, 969, 1]))
"""
digit = 0
n = int(input())
a = [int(i) for i in input().split()]
print(func(n, a))