import itertools
n = int(input())
a = list(map(int,input().split()))
arr = [0]
arr += list(itertools.accumulate(a))
ans = 0

_set = set(arr)
for i in _set:
    c = arr.count(i)
    ans += (c * (c - 1)) // 2

print(ans)
