n = int(input())
a = list(map(int, input().split()))
ca = [0] * (len(a) + 1)
for i in range(n):
    ca[i + 1] = ca[i] + a[i]

ans = 0
for i in range(n):
    # print(a[i], ca[i], ca, ca[i + 1:], ca[i + 1:].count(ca[i]))
    ans += ca[i + 1:].count(ca[i])
print(ans)
