n = int(input()) # 6
a = list(map(int, input().strip().split(' ')))

ary = []
uary = []
ary.append(0)
uary.append(0)
tmp = 0
for i in range(n):
	tmp = tmp+a[i]
	ary.append(tmp)
	if tmp not in uary:
		uary.append(tmp)
cnt = 0
for j in uary:
	t = 0
	for k in range(ary.count(j)):
		t = t + k
	cnt = cnt + t
print(cnt)