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).GroupBy(x=>x);
        var sum = 0;
        foreach (var item in cum)
        {
            sum += item.Count() * (item.Count() - 1) / 2;
        }
        WriteLine(sum);
    }
    public static IEnumerable<int> CumulativeSum(IEnumerable<int> array)
    {
        yield return 0;
        var tmp = 0;
        foreach (var num in array)
            yield return tmp += num;
    }
}