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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES": "NO");

		static void Main(string[] args)
		{
			var N = RI;
			var A = RIs;
			long[] a = new long[A.Length];
			a[0] = A[0];
			long ans = (a[0] == 0) ? 1 : 0;
			for (int i = 1;i < A.Length;i++)
			{
				a[i] = a[i - 1] + A[i];
				if (a[i] == 0) ans++;
			}
			for(int i = 0;i < A.Length;i++)
			{
				for(int j = i + 1;j < A.Length;j++)
				{
					if (a[j] == a[i]) ans++;
				}
			}
			Out(ans);
		}
	}
}
