using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string t = Console.ReadLine();
		int N = int.Parse(t);
		string[] s = Console.ReadLine().Split(' ');
		int [] A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(s[i]);
		}
		int count = 0;
		Dictionary<int, int> dic = new Dictionary<int, int>();
		dic[0] = 1;
		int sum = 0;
		for(var i=0;i<N;i++){
			sum += A[i];
			bool b = dic.ContainsKey(sum);
			if(b){
				count += dic[sum];
				dic[sum] += 1;
			} else {
				dic[sum] = 1;
			}
		}
		Console.WriteLine(count);
	}
}