N = int(input())
a_list = list(map(int, input().split()))
a_sum = [0]

ans = 0

for i in range(N):
    a_sum.append(a_sum[i] + a_list[i])

# print(a_sum)
a_set = list(set(a_sum))
# print(a_set)
for i in range(len(a_set)):
    n = a_sum.count(a_set[i]) 
    ans += n * (n-1) / 2
print(int(ans))