N = int(input())
A = list(map(int, input().split()))
csum = list()
csum_set = dict()
ans = 0
for i in range(0, len(A)):
    list.append
    if i == 0:
        csum.append(A[i])
    else:
        csum.append(csum[i - 1] + A[i])
        if csum[i] == 0:
            ans += 1

for x in csum:
    if str(x) not in csum_set:
        csum_set[str(x)] = 1
    else:
        csum_set[str(x)] += 1
    
for x in csum_set.values():
    if x >= 2:
        ans += x * (x - 1) // 2

print(ans)
