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


public class A
{
	public static void Main()
	{
		int N = GetInt();
		long[] csum = new long[N+1];
		for(int i = 1; i <= N; i++)
			csum[i] = GetLong();
		
		var num = new Dictionary<long, int>();
		num[0] = 1;
		for(int i = 1; i <= N; i++)
		{
			csum[i] += csum[i-1];
			int current = 0;
			num.TryGetValue(csum[i], out current);
			num[csum[i]] = current + 1;
		}

		long ans = 0;
		foreach(long key in num.Keys)
			ans += (num[key] * (num[key] - 1)) / 2;
		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}