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


def ni(i):
    return int(bin(i)[2:])


def hantei(l):
    sum_num = str(sum(l))
    if "2" not in sum_num:
        return True
    else:
        return False


for i in range(N):
    ll[i] = ni(ll[i])

count = 0
left = 0
right = 0

for left in range(N):
    while True:
        if right == N+1:
            break
        if hantei(ll[left:right]):
            pass
        else:
            break
        right += 1

    count += right - left - 1

print(count)

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

l, r = 0, 0
sum_a = 0
ans = 0
while r < n:
    # 右端を進める
    if sum_a & a[r] == 0:
        sum_a += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum_a -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)

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


def ni(i):
    return int(bin(i)[2:])


for i in range(N):
    ll[i] = ni(ll[i])

count = N
s = N
for i in range(N):
    s = ll[i]

    for j in range(i+1, N):
        s = s + ll[j]
        if "2" in str(s):
            break
        else:
            count += 1
print(count)




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

l, r = 0, 0
sum_a = 0
ans = 0
while r < n:
    # 右端を進める
    if sum_a & a[r] == 0:
        sum_a += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum_a -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ll = list(map(int, input().split(" ")))
# print(N)
# print(ll)


def ni(i):
    return int(bin(i)[2:])


for i in range(N):
    ll[i] = ni(ll[i])

# print(ll)

count = N
for i in range(N):
    for j in range(i+1, N):
        # print(i, j)
        sum_num = str(sum(ll[i:j+1]))
        # print(sum_num)
        if "2" not in sum_num:
            # print("yes")
            count += 1
        else:
            break

print(count)




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

l, r = 0, 0
sum_a = 0
ans = 0
while r < n:
    # 右端を進める
    if sum_a & a[r] == 0:
        sum_a += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum_a -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ll = list(map(int, input().split(" ")))
# print(N)
# print(ll)


def ni(i):
    return int(bin(i)[2:])


for i in range(N):
    ll[i] = ni(ll[i])

# print(ll)

count = 0
for i in range(N):
    for j in range(i, N):
        l = i
        r = j
        # print(i, j)
        sum_num = str(sum(ll[i:j+1]))
        # print(sum_num)
        if "2" not in sum_num:
            # print("yes")
            count += 1
        else:
            break

print(count)




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

l, r = 0, 0
sum_a = 0
ans = 0
while r < n:
    # 右端を進める
    if sum_a & a[r] == 0:
        sum_a += a[r]
        r += 1
        ans += r - l
    # 右端と左端を進める
    elif l == r:
        l += 1
        r += 1
    # 左端を進める
    else:
        sum_a -= a[l]
        l += 1
    # print('l={}, r={}, size={}, ans={}, {}'.format(l, r, r - l, ans, a[l:r]))
print(ans)