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;

        for (int i = 0; i <= n; i++)
        {
            for(int j = 0; j <= n; j++)
            {
                if (i < j)
                {
                    var sum = cSum.GetSum(i, j);
                    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];
    }
}