n = int(input())
lis = list(map(int,input().split()))
li = [0]
for i in range(n):li.append(li[-1]+lis[i])
ans = 0
num = 0
li.sort()
for i in range(n):
  if li[i] == li[i+1]:
    num += 1
    ans += num
  else:num = 0
print(ans)