import collections
n = int(input())
a = list(map(int, input().split()))
po = []
num = 0
po.append(num)
for i in a:
    num += i
    po.append(num)

po.sort()
ans = 0
aaaa = 0
for i in po:
    if aaaa == i:
        ans += 1
    aaaa = i
print(ans-1)