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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var aArray = Console.ReadLine().Split(' ');
            var aList = aArray
                .Select(x => int.Parse(x))
                .ToList();

            var c = aList
                .Select((x, y) => CountZero(aList.Skip(y + 1), x));

            Console.WriteLine(c.Sum());
        }

        static int CountZero(IEnumerable<int> list, int sum)
        {
            var count = 0;
            if (list.Count() != 0)
            {
                var x = list.First();
                if (sum + x == 0)
                {
                    count += 1;
                    //Console.WriteLine("{0} + {1}", sum, x);
                }
                count += CountZero(list.Skip(1), sum + x);
            }
            return count;
        }
    }
}
