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

ans = 0

b = [0]
for i in range(n):
    b.append(b[i] + a[i])
for x in list(set(b)):
    b_num = b.count(x)
    ans += sum([i for i in range(b_num)])
    
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

b = [0]
for i in range(n):
    b.append(b[i] + a[i])
for x in list(set(b)):
    b_num = b.count(x)
    ans += int(b_num * (b_num - 1) / 2)
    
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = [0]

for i in range(n):
    b.append(b[i] + a[i])

print(sum([sum([i for i in range(b.count(x))]) for x in set(b)]))

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

for i in range(n):
    sums = 0
    for j in range(n - i):
        new_sum = sums + a[i + j]
        if new_sum == 0:
            ans += 1
        sums = new_sum
        
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

for i in range(n):
    sums = [0] * (n - i +  1)
    for j in range(n - i):
        sums[j + 1] = sums[j] + a[i + j]
    ans += sums.count(0) - 1
        
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

for i in range(n):
    sums = a[i:]
    for j in range(n - i - 1):
        sums[j + 1] = sums[j] + sums[j + 1]
    ans += sums.count(0)
        
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

sums = []

for i in range(n):
    sums +=  [sum(a[i:j+1]) for j in range(i, n)]

print(sums.count(0))

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

b = [0]
for i in range(n):
    b.append(b[i] + a[i])
for x in list(set(b)):
    b_num = b.count(x)
    ans += sum([i for i in range(b_num)])
    
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)

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

ans = 0

for i in range(n):
    sum_list = [sum(a[i:j]) for j in range(i + 1, n + 1)]
    ans += sum_list.count(0)
    
print(ans)

Fixed submission:
from collections import Counter

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

ans = 0

b = [0]
for i in range(n):
	b.append(b[i] + a[i])

c = Counter(b)

for value in c.values():
	ans += value * (value - 1) // 2
    
print(ans)