n = int(input())
a = list(map(int, input().split()))

s=[0]
sm=0
for i in a:
    sm+=i
    s.append(sm)
s.sort()
import collections
c = collections.Counter(s)

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ans=0
for v in c.values():
    if v>1:
        ans+=combination(v,2)

print(int(ans))