N = int(input())
A = list(map(int, input().split()))

asum = [0]
for a in A:
	asum.append(asum[-1] + a)
#print(asum)
count = 0
for l in range(N + 1):
	for r in range(l + 1, N + 1):
		if (asum[r] - asum[l]) == 0:
			count += 1
			#print(l, r)
print(count)
