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

count = 0

for i in range(len(li)) :
  for j in range(len(li)) :
    if sum(li[i:i+j+1]) == 0:
      count = count + 1
    if i + j >= len(li) - 1:
      break

print(count)
