N = int(input())
A_li = list(map(int, input().split()))
s_li = [0]
for i in range(N) :
    s_li.append(s_li[i] + A_li[i])
s_num = set(s_li)
ans = 0
for sn in s_num :
    cnt = s_li.count(sn)
    ans += cnt * (cnt - 1) // 2
print(ans)