n = int( raw_input() )
a = map(int, raw_input().split())

ans = 0
s = 0
l, r = 0, 0
sections = {}
sec = []
for _a in a:
    s += _a
    if s == 0:
        ans += 1
        sections.setdefault( l, [l, r] )
        sec.append( [l, r] )
        l = r
        s = _a
    r += 1

for ss in sec:
    if ss[1]+1 in sections:
        ss2 = sections[ss[1]+1]
        sec.append([ss[0], ss2[1]])

print len(sec)