using System;
using System.Linq;

namespace Zero_Sum_Ranges
{
    class Program
    {
        static void Main(string[] args)
        {
            var _N = int.Parse(Console.ReadLine());
            var _As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            var accumulation = new long[_N + 1];
            accumulation[0] = 0;
            for (var i = 1; i <= _N; i++)
            {
                accumulation[i] = accumulation[i - 1] + _As[i - 1];
            }

            var count = 0;
            for(var i = 0; i < _N; i++)
            {
                for(var j = i; j < _N; j++)
                {
                    if(accumulation[j + 1] - accumulation[i] == 0)
                    {
                        count++;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}
