using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        //static int N;
        //static long mod = 1000000007;
        //static char[] az = Enumerable.Range('a', 'z' - 'a' + 1).Select(i => (Char)i).ToArray();
        static void Main(string[] args)
        {
            //var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var N = long.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();

            var dic = new SortedDictionary<long,long>();
            long sum = 0;
            long ans = 0;
            bool zero = false;
            for (int i = 0; i < N; i++)
            {
                if (A[i] == 0)
                {
                    ans++;
                }
                sum += A[i];

                if (sum == 0 && A[i] != 0)
                {
                    ans++;
                }

                if (dic.ContainsKey(sum))
                {
                    ans += dic[sum];
                    dic[sum]++;
                }
                else
                {
                    dic.Add(sum, 1);
                }
            }
            Console.WriteLine(ans);

        }
    }
}
