Buggy python submission (verdict: Time Limit Exceeded):
pp = int(input()) + 1
da = list(map(int,input().split()))
da.insert(0,0)
al = 0
if da[0] == 0:
  al += 0
for k in range(1,pp):
  da[k] += da[k-1]
  if da[k]== 0:
        al += 1
for i in range(1,pp):
    for j in range(1,pp-i):
      if da[i+j] - da[i] == 0:
        al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
da.insert(0,0)
al = 0
if da[0] == 0:
  al += 0
for k in range(1,len(da)):
  da[k] += da[k-1]
  if da[k]== 0:
        al += 1
for i in range(1,len(da)):
    for j in range(1,len(da)-i):
      if da[i+j] - da[i] == 0:
        al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
da.insert(0,0)
al = 0
for k in range(1,len(da)):
  da[k] += da[k-1]
  if da[k]== 0:
        al += 1
for i in range(1,len(da)):
    for j in range(1,len(da)-i):
      if da[i+j] - da[i] == 0:
        al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
al = 0
ta = [0]*len(da)
for i in range(len(da)):
  if i == 0:
    for j in range(len(da)-i):
     ta[j] = sum(da[i:j+1])
     if ta[j] == 0:
      al  += 1
  else:
    for j in range(len(da)-i):
      ta[j+i] -= da[i -1]
      if ta[j+i] == 0:
        al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
al = 0
ta = [0]*len(da)
for i in range(len(da)):
  if i == 0:
    for j in range(len(da)-i):
      if j == 0:
        ta[0] = da[i]
      else:
        ta[j] = ta[j-1] + da[i+j]
      if ta[j] == 0:
        al += 1
  else:
    for j in range(len(da)-i):
      ta[j+i] -= da[i -1]
      if ta[j+i] == 0:
        al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
al = 0
ta = [0]*len(da)
for i in range(len(da)):
  for j in range(len(da)-i):
    if j == 0:
      ta[0] = da[i]
    else:
      ta[j] = ta[j-1] + da[i+j]
    if ta[j] == 0:
      al += 1
print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
input()
da = list(map(int,input().split()))
al = 0
for i in range(len(da)):
  for j in range(len(da)-i):
    if sum(da[i:j+i+1]) == 0:
      al += 1

print(al)

Fixed submission:
from collections import defaultdict
 
n = int(input())
a = [int(i) for i in input().split()]
 
s = 0
d = defaultdict(int)
ans = 0
d[0] = 1
 
for i in a:
    s += i
    ans += d[s]
    d[s] += 1
 
print(ans)