import numpy as np

N = int(input())

A = list(map(int, input().split()))
X = np.zeros(N+1, dtype='int64')

for i in range(1,N+1): # 1 から N まで
    X[i] = X[i-1] + A[i-1]

ans = 0
for l in range(1,N+1): # 1 から N まで
    for r in range(l,N+1): # l から N まで
        if X[r] - X[l-1] == 0: ans += 1
print(ans)