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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse).ToList();
            long ans = 0;

            while (a.Count() >= 2)
            {
                long L = 0;
                long R = a.Sum() - a[0];
                a.Add(0);
                for (int i = 0; i < a.Count() - 1; i++)
                {
                    if (L == 0) ans++;
                    if (R == 0) ans++;
                    L += a[i];
                    R -= a[i + 1];
                }
                ans -= 2;
                if (L == 0) ans++;
                a.RemoveAt(0);
                a.RemoveRange(a.Count() - 2, 2);
            }

            Console.WriteLine(ans);
        }
    }
}