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


class Program {

	const long mod = 1000000007;
	//public static int[] max;

	static void Main(string[] args) {

		char[] cs = new char[] { ' ', ',' };
		//int val = int.Parse(Console.ReadLine());
		//int[] vals = parseAry(Console.ReadLine().Split(cs));
		//string str = Console.ReadLine();
		//string[] strs = Console.ReadLine().Split(cs);

		//string res="";
		long res=0;
		int n = int.Parse(Console.ReadLine());

		long[] vals = parseAryL(Console.ReadLine().Split(cs));

		long[] left = new long[n];
		left[0] = vals[0];
		for (int i = 1; i < n; i++) {
			left[i] = left[i - 1] + vals[i];
		}


		for (int i = 0; i < n; i++) {

			for (int k = i; k < n; k++) {
				if (i == 0) { if (left[k] == 0) { res++; } } else {
					if (left[k] - left[i - 1] == 0) { res++; }
				}
			}
		}


			//deug
			Console.WriteLine(res);

		return;
	}


	//　String[]  ----->  int[]
	static int[] parseAry(string[] str) {
		int[] nums = new int[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = int.Parse(str[i]); }
		return nums;
	}
	//　String[]  ----->  long[]
	static long[] parseAryL(string[] str) {
		long[] nums = new long[str.Length];
		for (int i = 0; i < str.Length; i++) { nums[i] = long.Parse(str[i]); }
		return nums;
	}



	//文字列を1文字ずつString[]に入れる
	static string[] strAry(String str) {
		string[] re = new string[str.Length];
		for (int i = 0; i < str.Length; i++) { re[i] = str[i].ToString(); }
		return re;
	}

}