import itertools
n = int(input())
a = list(map(int,input().split()))
arr = [0]
ans = 0
for i, j in enumerate(a):
    arr.append(arr[i] + j)

_set = set(arr)
for i in _set:
    c = arr.count(i)
    if c == 2:
        ans += 1
    elif c > 2:
        ans += len(list(itertools.combinations(range(c), 2)))

print(ans)