n = int(input())
a = list(map(int, input().split()))

ans = 0
m = {}
s = [0] * (10 ** 5 + 10)
# 累積和
for i in range(n):
  s[i+1] = s[i] + a[i]
#print(s[:10])
# 出現数
for i in range(n+1):
  if s[i] in m:
    m[s[i]] += 1
  else:
    m[s[i]] = 1
#print(m)
# 集計
ans = 0
for i in m:
  if m[i] < 2:
    continue
  ans += (m[i] * (m[i]-1)) // 2
print(ans)