Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)


#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + chk*(chk-1)//2

print(ans)




Fixed submission:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)


#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

#c = [0]*(n+1)
#c = copy.copy(b)
#c = list(set(c))
#print(c)

import collections
c = collections.Counter(b)
#print(c)
#print(c.values())

ans = 0

for i in c.values():
	#print(i)
	#chk = b.count(i)

	#print(chk)
	if i >= 2:
		ans = ans + i*(i-1)//2

print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

#nCrの計算。nこの中から、r個を取り出す。
import import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

#読み込みの高速化
input = sys.stdin.readline

#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + combinations_count(chk,2)

print(ans)



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + combinations_count(chk,2)

print(ans)




Fixed submission:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)


#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

#c = [0]*(n+1)
#c = copy.copy(b)
#c = list(set(c))
#print(c)

import collections
c = collections.Counter(b)
#print(c)
#print(c.values())

ans = 0

for i in c.values():
	#print(i)
	#chk = b.count(i)

	#print(chk)
	if i >= 2:
		ans = ans + i*(i-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

c = [0]*(n+1)
c = copy.copy(b)
c = list(set(c))
#print(c)

ans = 0

for i in c:
	#print(i)
	chk = b.count(i)
	#print(chk)
	if chk >= 2:
		ans = ans + combinations_count(chk,2)

print(ans)




Fixed submission:
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)


#nCrの計算。nこの中から、r個を取り出す。
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

import copy


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

b = [0]*(n+1)
b[0] = 0
for i in range(1,n+1):
	b[i] = b[i-1] + a[i-1]

#print(b)

#c = [0]*(n+1)
#c = copy.copy(b)
#c = list(set(c))
#print(c)

import collections
c = collections.Counter(b)
#print(c)
#print(c.values())

ans = 0

for i in c.values():
	#print(i)
	#chk = b.count(i)

	#print(chk)
	if i >= 2:
		ans = ans + i*(i-1)//2

print(ans)