# -*- coding: utf-8 -*-
# 整数の入力
import sys
n = int(input())
li = list(map(int, input().split()))

count = 0
table = {}

for i in range(len(li)) :
  sum = 0
  if i in table.keys() :
    count += table[i]
    continue

  match_i = list()

  for j in range(len(li)-i) :
    sum = sum + li[i+j]
    if sum == 0:
      count = count + 1
      for k in match_i:
        table[k] = table[k] + 1
      table[i+j+1] = 0
      match_i.append(i+j+1)

print(count)
#print(table)