n = int(input())

a = list(map(int, input().split()))
cnt = 0
b = 0
c = []
for i in range(n):
    b += a[i]
    if b == 0:
        cnt += 1
    if b in c:
       cnt += 1
    c.append(b)
            
print(cnt)