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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var cumsum = new List<long>();
            var tmp = (long)0;
            var result = 0;
            foreach (var i in Enumerable.Range(0, N))
            {
                tmp += A[i];
                if (tmp == 0) result++;
                cumsum.Add(tmp);
            }

            foreach(var i in Enumerable.Range(0, cumsum.Count))
            {
                for(var j = i+1; j<cumsum.Count; j++)
                {
                    var sum = cumsum[j] - cumsum[i];
                    if (sum == 0) result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}
