N = [int(_) for _ in input().split()][0]
a = [int(_) for _ in input().split()]

s = [0] * (len(a) + 1)
for i in range(len(a)):
    s[i + 1] = s[i] + a[i]

ans = 0
for l in range(len(a)):
    for r in range(l + 1, len(a) + 1):
        ans += s[r] - s[l] == 0
print(ans)

