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++;
                }
            }
        }
        WriteLine(sum);
    }
    public static int[] CumulativeSum(int[] array)
    {
        var res = new int[array.Length];
        res[0] = array[0];
        for (int i = 1; i < array.Length; i++)
        {
            res[i] = res[i - 1] + array[i];
        }
        return res;
    }
}
