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];
            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();
        }
    }
}
