import collections

N = int(input())
A = list(map(int, input().split()))
A_ = [0]
count = 0

for a in A:
    A_.append(a+A_[-1])

for v in collections.Counter(A_).values():
        count += sum([i for i in range(1, v)])

print(count)