import math
N = int(input())
A = list(map(int,input().split()))
ans = 0
s = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        s[i] = A[i]
    else:
        s[i] = A[i] + s[i-1]

ans += s.count(0)
for i in [s.count(x) for x in set(s)]:
    if i > 1:
        ans += math.factorial(i) // math.factorial(2) // math.factorial(i-2)

print(str(ans))
