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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var ak = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var cSum = new CumulativeSum(ak);

        var count = 0;

        foreach(var elem in Combination.Enumerate(Enumerable.Range(0,n), 2, true))
        {
            if (elem[0] < elem[1])
            {
                var sum = cSum.GetSum(elem[0], elem[1]);
                if (sum == 0) count++;
            }
        }

        Console.WriteLine(count);
    }
}

/// <summary>
/// 累積和
/// </summary>
public class CumulativeSum
{
    public long[] Array { get; }

    public CumulativeSum(int[] array) : this(array.Select(t => (long)t).ToArray()) { }

    public CumulativeSum(long[] array)
    {
        var length = array.Length;
        Array = new long[length + 1];

        for (int i = 0; i < length; i++)
        {
            Array[i + 1] = array[i] + Array[i];
        }
    }

    /// <summary>
    /// left以上right未満の総和
    /// </summary>
    /// <param name="left">以上</param>
    /// <param name="right">未満</param>
    public long GetSum(int left, int right)
    {
        if (left >= right) return 0;

        return Array[right] - Array[left];
    }
}

public static class Combination
{
    public static IEnumerable<T[]> Enumerate<T>(IEnumerable<T> items, int k, bool withRepetition)
    {
        if (k == 1)
        {
            foreach (var item in items)
                yield return new T[] { item };
            yield break;
        }
        foreach (var item in items)
        {
            var leftside = new T[] { item };

            // item よりも前のものを除く （順列と組み合わせの違い)
            // 重複を許さないので、unusedから item そのものも取り除く
            var unused = withRepetition ? items : items.SkipWhile(e => !e.Equals(item)).Skip(1).ToList();

            foreach (var rightside in Enumerate(unused, k - 1, withRepetition))
            {
                yield return leftside.Concat(rightside).ToArray();
            }
        }
    }
}