N = int(input())
A = list(map(int, input().split()))

S = []
s = 0
for i in A:
    s += i
    S.append(s)
#print(S)
S.sort()
#print(S)

ans = 0
n = 0
cnt = 1
for i in S:
    if i==n:
        cnt += 1
    else:
        n = i
        ans += cnt*(cnt-1)//2
        cnt = 1
ans += cnt*(cnt-1)//2
print(ans)
