using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var imp = Console.ReadLine().Split(' ');
            int[] ary = new int[N];
            for(int i = 0; i < N; i++)
            {
                ary[i] = int.Parse(imp[i]);
            }
            int sum = 0;
            int count = 0;
            for(int j = 1; j < N; j++)  //j文字の合計
            {
                int[] picked = new int[j];
                for (int k = 0; k < N - j + 1; k++)     //足し始める位置
                {
                    Array.Copy(ary, k, picked, 0, j);
                    sum = picked.Sum();
                    if(sum == 0)
                    {
                        count += 1;
                    }
                }
            }
            Console.Write(count);
            //System.Threading.Thread.Sleep(1000);
        }
    }
}
