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

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

s.sort()

c, comb, cnt = 0, 0, 0
for j in range(n):
    if s[j] == s[j+1]:
        cnt += 1
        if comb == 0:
            comb = 1
        else:
            comb *= cnt

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

if cnt != 0:
    c += comb

print(c)
