n = int,input()
a = list(map(int, input().split()))
total = []
ans = 0
dic = {0:1}
for i in range(0,len(a)):
    if(i == 0):
        total.append(a[0])
    else:
        total.append(total[i-1] + a[i])
        ans += dic.get(total[i],0)
    if total[i] in dic:
        dic[total[i]] += 1
    else:
        dic[total[i]] = 1
print(ans)
