using System;

namespace AtCoder.AGC023
{
    class a
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Trim();
            var N = int.Parse(line);
            line = Console.ReadLine().Trim();
            var A = Array.ConvertAll(line.Split(' '), new Converter<string, int>(s => int.Parse(s)));
            var cnt = 0L;
            for (var i = 0; i < A.Length; ++i)
            {
                var sum = 0L;
                for (var j = i; j < A.Length; ++j)
                {
                    sum += A[j];
                    if (sum == 0) ++cnt;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
