import itertools
N = int(input())
A = [int(_) for _ in input().split()]
cumsum = [0]
for a in A:
    cumsum += [cumsum[-1] + a]
ans = 0
for i, j in itertools.combinations(range(N + 1), 2):
    ans += cumsum[j]-cumsum[i] == 0
print(ans)
