n = int(input())
l = list(map(int, input().split()))
s = [0]
for i in range(n):
  s.append(s[i] + l[i])
s.sort()
s_unique = list(set(s))
ans = 0
for x in s_unique:
  cnt = s.count(x)
  ans += (cnt * (cnt - 1)) // 2
print(ans)