using System;
class Program
    {
    	static void Main(string[] args)
    	{
    		// 整数の入力
            int n = int.Parse(Console.ReadLine());
    		string[] input = Console.ReadLine().Split(' ');
            long[] a = new long[n];
            for (int i=0; i<n; i++) a[i] = long.Parse(input[i]);

    		long [] s = new long[n];
            s[0] = a[0];
            for(int i=1; i<n; i++) s[i] = s[i - 1] + a[i];

            Array.Sort(s);
            long p = 0;
            long count = 0;
            long ans = 0;
            for(int i=0; i<n; i++)
            {
                if (s[i] == p) count++;
                else
                {
                   p = s[i]; 
                   ans += count * (count + 1) / 2;
                   count = 0;
                } 
            }
            //p = s[i]; 
            ans += count * (count + 1) / 2;
            //count = 0;

    		//出力
            
            Console.WriteLine(ans);
        }
    }
    //mcs Main.cs
    //mono Main.exe