#  dataArray :
#     2
def i_input(): return int(input())

def i_map(): return map(int, input().split())


#  dataArray :
#     2 3 4
def i_list(): return list(i_map())

n=i_input()
aa=i_list()
tmp=[]
num=0
for a in aa:
    num+=a
    tmp.append(num)

cnt=tmp.count(0)
for i in range(n):
    for j in range(i+1,n):
        if tmp[j]-tmp[i]==0:
            cnt+=1
print(cnt)




