using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        int itemCount = int.Parse(Reader.ReadLine());
        long[] input = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        long[] total = new long[itemCount];

        total[0] = input[0];
        for (int i = 1; i < itemCount; i++) {
            total[i] = total[i - 1] + input[i];
        }

        long ans = 0;
        for (int i = 0; i < itemCount; i++)
        {
            long minus = 0;
            if (i > 0)
            {
                minus = total[i-1];
            }
            ans += total.Skip(i).Where(a => a == minus).Count();
        }
        Console.WriteLine(ans);
    }



    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


7
1 -1 1 -1 1 -1 1




";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
