n = int,input()
a = list(map(int, input().split()))
wa = []
ans = 0
wa.append(a[0])
for i in range(1,len(a)):
    wa.append(wa[i-1] + a[i])
ans += wa.count(0)
for i in range(0,len(a)):
    wa2 = []
    wa2 = list(map(lambda x: x-wa[i], wa))
    wa3 = wa2[i+1:]
    ans += wa3.count(0)
print(ans)
