n = int(input())
a = list(map(int, input().split()))

#累積和の計算
s = [0]
for i in range(n):
    s.append(s[i]+a[i])

#条件を満足する部分列を探索
ans = 0
for i in range(n-1):
    for j in range(i+1, n+1):
        if s[j] - s[i] == 0:
            ans += 1

#出力
print(ans)

