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

print(d)