N = int(input())
A = list(map(int,input().split()))
B = [A[0] for i in range(N)]
d = 0
for i in range(1,N):
	B[i]=B[i-1]+A[i]
for j in range(N):
	if B[j]==0:
		d = d+1
	for k in range(j+1,N):
		if B[j]==B[k]:
			d = d+1

print(d)