from collections import defaultdict

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

s = [0 for i in range(n+1)]
nums = {}
nums = defaultdict(int)
for i in range(0,n):
	s[i+1] = s[i] + a[i]

for i in range(0,n):
	nums[s[i]]+=1

res = 0
for key in nums:
	#print("key ",key," value ",nums[key])
	res += nums[key] * (nums[key] - 1) / 2

print(int(res))