using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var A = Sarray();
            var dct = new Dictionary<long, long>();
            dct[0] = 1;
            var sum = 0L;
            foreach(var a in A)
            {
                sum += a;
                if (!dct.ContainsKey(sum)) dct[sum] = 0;
                ++dct[sum];
            }
            var ans = 0L;
            foreach(var d in dct)
                ans += d.Value * (d.Value - 1) / 2;
            WriteLine(ans);
            //Out.Flush();
        }
    }
