using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var array = ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var cum = CumulativeSum(array).ToArray();
        var current = 0;
        var sum = cum.Count(x => x == 0);
        for (int i = 1; i < array.Length; i++)
        {
            current = cum[i - 1];
            for (int j = i; j < array.Length; j++)
            {
                if (cum[j] == current)
                {
                    sum++;
                }
            }
        }
        //for (int i = 0; i < array.Length-2; i++)
        //{
        //    cum = RemoveFirst(cum).ToArray();
        //    sum += cum.Count(x => x == 0);
        //}
        WriteLine(sum);
    }
    public static IEnumerable<int> RemoveFirst(IEnumerable<int> array)
    {
        var tmp = array.ToArray();
        for (int i = 1; i < array.Count(); i++)
        {
            yield return tmp[i];
        }
    }
    public static IEnumerable<int> CumulativeSum(IEnumerable<int> array)
    {
        var tmp = 0;
        foreach (var num in array)
            yield return tmp += num;
    }
}