# -*- coding: utf-8 -*-
"""
Created on Sat Apr 28 21:01:55 2018

@author: Kim
"""

N = int(input())
A = input().split()
A = [ int(x) for x in A]
n = []
ans = 0
for i in range(N):
    n.append(N-i)


for i in range(N):
    wa = 0
    for j in range(n[i]):
        j = j + i + 1
        
        if j == 0:
            RANGE = A[i:j]
            wa = sum(RANGE)
        else:
            wa = wa + A[j-1]
        #print(i, j, wa)

        if wa == 0:
            ans += 1
            """ 
            if j != (N-1) and A[j+1] != 0:
                j = j + 1
            """
print(ans)
