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

namespace AGC023A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var sum = new long[N + 1];
            for(int i = 1; i <= N; i++)
            {
                sum[i] = sum[i - 1] + Ai[i - 1];
            }

            //var sum2 = sum.OrderBy(x => x).ToList();
            int ans = 0;
            //long count = 0;
            //long now = sum2[0];
            //while (true)
            //{
            //    long now = sum2[0];
            //    int count = 1;
            //    for (int i = 1; i <= sum2.Count; i++)
            //    {
            //        if (i == sum2.Count) sum2 = new List<long>();
            //        else if (sum2[i] == now) count++;
            //        else
            //        {
            //            sum2 = sum2.Skip(count).ToList();
            //            break;
            //        }
            //    }
            //    ans += (int)(count * (count - 1) / 2);
            //    if (sum2.Count == 0) break;
            //}

            var dislist = sum
                .GroupBy(i => i)
                .Where(g => g.Count() > 1)
                .Select(g => new { number = g.Key, duplicationCount = g.Count()})
                .ToList();

            foreach(var d in dislist)
            {
                ans += (int)(d.duplicationCount * (d.duplicationCount - 1) / 2);
            }

            //for (int i = 0; i < N + 1; i++)
            //{
            //    if (sum2[i] == now)
            //    {
            //        count++;
            //        continue;
            //    }
            //    ans += (int)(count * (count - 1) / 2);
            //    count = 1;
            //    now = sum2[i];
            //}
            //ans += (int)(count * (count - 1) / 2);

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}
