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

namespace AGC23
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            var a = ReadLine().Split().Select(long.Parse).ToArray();
            var sum = new long[n + 1];
            sum[0] = 0;
            for (int i = 0; i < n; i++)
            {
                sum[i + 1] = sum[i] + a[i];
            }
            Array.Sort(sum);
            var c = new Dictionary<long, int>();
            for (int i = 1; i < n + 1; i++)
            {
                
                if(sum[i] == sum[i - 1])
                {
                    if (!c.ContainsKey(sum[i])) c[sum[i]] = 1;
                    c[sum[i]] += 1;
                }
            }
            long count = 0;
            foreach(var cc in c)
            {
                count += Math.Max(cc.Value * (cc.Value - 1) / 2, 1);
            }
            WriteLine(count);
        }
    }
}