n = int(input())
a = list(map(int, input().split()))
s = [0]

for i in range(n):
    s.append(s[i]+a[i])

s.append(10000000000)
s.sort()

c, comb, cnt, idx = 0, 0, 0, 0
while idx <= n:
    if s[idx] == s[idx+1]:
        cnt += 1
        if cnt == 1:
            comb = 1
        comb *= cnt

    else:
        c += comb
        cnt, comb = 0, 0

    idx += 1

print(c)
