def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

INF = int(1e9) + 7
n = int(input())
a = list(map(int, input().split()))
s = [0]*(n+1)
for i in range(n):
    s[i+1] = s[i] + a[i]
s[0] = INF
s.sort()
c = 1
x = s[0]
ans = 0

if x==0:
    ans +=1

for i in range(1,n+1):
    if s[i]==0:
        ans +=1

    if x==s[i]:
        c +=1
    else:
        if c>1:
            ans += cmb(c,2)
        c = 1
        x = s[i]
print(ans)