import math
N = int(input())
c=0

a=[]
s = input().rstrip().split()
for i in range(N):
    a.append(int(s[i]))

for i in range(N):
    sum = a[i]
    for j in range(N - i-1):
        sum += a[i + j + 1]
        if sum == 0:
            c+=1


print(c)