Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = N
for i in range(0,N):
    t = A[i]
    for j in A[i+1:N]:
        if not (t & j):
            R += 1
            t += j
        else:
            break
print(R)


Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = N
for i in range(0,N):
    t = A[i]
    for j in range(i+1,N):
        if not (t & A[j]):
            R += 1
            t += A[j]
        else:
            break
print(R)


Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = N
L = [True] * N
for i in range(1,N):
    #L = [L[j] and L[j+1] and A[j]^A[i+j] == A[j]+A[i+j] for j in range(N-i)] + [False]*(i) 
    L = [L[j] and L[j+1] and not (A[j] & A[i+j]) for j in range(N-i)] + [False]*(i) 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = N
L = [True] * N
for i in range(1,N):
    L = [L[j] and L[j+1] and A[j]^A[i+j] == A[j]+A[i+j] for j in range(N-i)] + [False]*(i) 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = tuple(map(int,input().split()))

R = N
L = np.zeros((N,N), dtype='bool')
L[0,:] = 1
for i in range(1,N):
    t = 0
    L[i,:] = np.array( [L[i-1][j] and L[i-1][j+1] and A[j]^A[i+j] == A[j]+A[i+j] for j in range(N-i)] + [False]*(i) )
    t = L[i].sum()
    R += t
    if t == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = 0
L = []
for i in range(N):
    if i == 0:
        L = [True] * N
    else:
        L = [L[j] and L[j+1] and A[j]^A[i+j] == A[j]+A[i+j] for j in range(N-i)] + [False]*(i) 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = 0
L = tuple()
for i in range(N):
    if i == 0:
        L = (True,) * N
    else:
        L = tuple(L[j] and A[j]^A[i+j] == A[j]+A[i+j] and L[j+1] for j in range(N-i)) + (False,) * i 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = tuple(map(int,input().split()))

R = 0
L = tuple()
for i in range(N):
    if i == 0:
        L = (True,) * N
    else:
        L = (L[j] and A[j]^A[i+j] == A[j]+A[i+j] and L[j+1] for j in range(N-i)) + (False,) * i 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = tuple(map(int,input().split()))
R = 0
L = tuple()
for i in range(N):
    if i == 0:
        L = (True,) * N
    else:
        L = (L[j] and A[j]^A[i+j] == A[j]+A[i+j] and L[j+1] for j in range(N-i)) + (False,) * i 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

R = 0
L = []
for i in range(N):
    if i == 0:
        L = [True] * N
    else:
        L = [L[j] and A[j]^A[i+j] == A[j]+A[i+j] and L[j+1] for j in range(N-i)] + [False]*(i) 
    R += sum(L)
    if sum(L) == 0:
        break
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = tuple(map(int,input().split()))
L = np.array([[int(A[i]^A[i+j] == A[i]+A[i+j]) for i in range(N-j)] + [0]*(j) for j in range(N)])
L[0,:]=1 

R = 0
for i in range(N):
    for j in range(1,N):
        try:
            L[j][i] = L[j][i] and L[j-1][i+1]
            if not L[j][i]:
                L[j:N,i] = 0
                break
        except IndexError:
            break

for i in L:
    a = sum(i)
    if a == 0:
        break
    R += a

print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))
L = [[int(A[i]^A[i+j] == A[i]+A[i+j]) for i in range(N-j)] for j in range(1,N)]
R = N
for i in range(N-1):
    if not L[0][i]:
        try:
            for k in range(1,N-1):
                L[k][i] = 0
        except:
            pass
        else:
            break

    for j in range(1,N-1):
        try:
            L[j][i] = L[j][i] and L[j-1][i+1]
            if not L[j][i]:
                for k in range(j,N-1):
                    L[k][i] = 0
                break
        except IndexError:
            break
for i in L:
    a = sum(i)
    if a == 0:
        break
    R += a
print(R)

Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int,input().split()))

result = 0
for i in range(N):
    for j in range(i,N):
        tmp = A[i]
        for k in A[i+1:j+1]:
            tmp ^= k
        if tmp == sum(A[i:j+1]):
            result += 1

print(result)



Fixed submission:
N = int(input())
A = tuple(map(int,input().split()))

result = 0
Right = 0
tmp = 0
for left in range(N):
    for right in range(Right,N):
        if not (tmp & A[right]):
            tmp += A[right]
            Right = right + 1
        else:
            break
    tmp -= A[left]
    result += Right - left
print(result)