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

C = []
ans = 0
for i in range(N):
    C.append(0)
    C = list(map(lambda x:x+A[i],C))
    ans += len(list(filter(lambda x:x==0,C)))
    
print(ans)