using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var aList = Console.ReadLine()
                .Split(' ')
                .Select(x => int.Parse(x))
                .ToList();

            var count = 0;
            var memo = new Dictionary<int, int>();
            foreach (var a in aList)
            {
                var next = new Dictionary<int, int>();
                foreach (var m in memo)
                {
                    if (next.ContainsKey(m.Key + a))
                        next[m.Key + a] += 1;
                    else
                        next[m.Key + a] = m.Value;
                }
                memo = next;

                if (memo.ContainsKey(a))
                    memo[a] += 1;
                else
                    memo[a] = 1;

                if (memo.ContainsKey(0))
                    count += memo[0];
            }

            Console.WriteLine(count);
        }
    }
}
