N = int(raw_input())
A = map(int, raw_input().split())
S = [sum(A[:i+1]) for i in range(N)]

ans = 0
d = {0:1}

for s in S:
    if s in d:
        ans += d[s]
        d[s] += 1
    else:
        d[s] = 1

print ans
