N = int(input())
A = [int(i) for i in input().split(" ")]

count = 0
for n in range(N):
    if A[n] == 0:
        count += 0
    elif A[n] > 0:
        pass
    else:
        k = n-1
        tmp = A[n]
        while 0 <= k:
            tmp += A[k]
            if tmp == 0:
                count += 1
            k -=1
        k = n+1
        tmp = A[n]
        while k <= N-1:
            tmp += A[k]
            if tmp == 0:
                count += 1
            k += 1
print(count)