Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for l in range(n):
        s = 0
        for r in range(l,n):
            if not s & a[r]:
                s += a[r]
                ans += 1
            else:
                break

    print(ans)

if __name__ == '__main__':
    d()


Fixed submission:
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:
                break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)

if __name__ == '__main__':
    d()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    bit = [[] for _ in range(n)]
    for i in range(n):
        for j in range(20):
            if (a[i] >> j) & 1:
                bit[i].append(j)
    for r in range(n):
        for l in range(r+1):
            b = [item for i in range(l,r+1) for item in bit[i]]
            t = list(set(b))
            if len(b) == len(t):
                ans += 1
    print(ans)

if __name__ == '__main__':
    d()


Fixed submission:
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:
                break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)

if __name__ == '__main__':
    d()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    bit = [[] for _ in range(n)]
    for i in range(n):
        for j in range(20):
            if (a[i] >> j) & 1:
                bit[i].append(j)
    for r in range(n):
        for l in range(r+1):
            s = []
            f = 1
            for c in range(l,r+1):
                for b in bit[c]:
                    if b not in s:
                        s.append(b)
                    else:
                        f = 0
                        break
                if not f:
                    break
            if f:
                ans += 1
    print(ans)

if __name__ == '__main__':
    d()


Fixed submission:
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:
                break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)

if __name__ == '__main__':
    d()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    for r in range(n):
        for l in range(r+1):
            s = []
            f = 1
            for c in a[l:r+1]:
                for k in range(20):
                    if (c >> k) & 1:
                        if k in s:
                            f = 0
                            break
                        else:
                            s.append(k)
                if not f:
                    break
            if f:
                ans += 1
    print(ans)

if __name__ == '__main__':
    d()


Fixed submission:
#!/usr/bin/env python3
#ABC98 D

import sys
input = sys.stdin.readline
def d():
    n = int(input())
    a = list(map(int,input().split()))
    ans = 0
    l = 0
    r = 0
    s = 0
    while l < n and r < n:
        while s&a[r] == 0:
            s += a[r]
            r += 1
            ans += r-l
            if r == n:
                break
        if l==r:
            s += a[r]
            r += 1
        s -= a[l]
        l += 1
    print(ans)

if __name__ == '__main__':
    d()