n = int(input())
A = map(int,input().split())
ans = 0
S = [0]*(n)
sm = 0
import math
def Comb(a,b):#aCbを返す
    if a>= b:
        return int(math.factorial(a)/(math.factorial(b)*math.factorial(a-b)))
    else:
        return 0

for a,i in zip(A,range(n)):
    sm += a
    S[i] = sm
S.sort()
temp = S[0]
t = 1
for s in S[1:]:
    if temp == s:
        t += 1
    else:
        ans += Comb(t,2)
        t = 1
    temp = s
ans += Comb(t,2)
for s in S:
    if s == 0:
        ans += 1
    else:
        break
print(ans)
