N = int(input())
MMM = map(int,input().split())
MM = list(MMM)
count = 0
for i in range(N):
  
  for j in range(i+1,N+1):
    total = 0
    for k in range(i,j):
      total += MM[k]
    if total ==0:
      
      count +=1
x = MM.count(0)
print(count+x)