N = int(input())
A = list(map(int, input().split()))

cur = 0
d = {0: 1}
for i in range(N):
  cur = cur + A[i]
  d[cur] = d.get(cur, 0) + 1

ans = 0
for v in d.values():
  ans += v * (v-1) // 2

print(ans)