n=int(input())
lists=list(map(int,input().split()))
listsa=[0]
s=0
for i in range(n):
    s+=lists[i]
 
    listsa.append(s)
uselists=sorted(listsa)
print(uselists)
import collections
ans=collections.Counter(uselists)
a=0
for i in ans.values():
    a+=i-1
print(a)