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 b = Array.ConvertAll(Console.ReadLine().Split(), long.Parse).ToList();
            var a = new List<long>();
            a = Enumerable.Repeat((long)0, b.Count()).ToList();
            long ans = 0;
            for (int i = 0; i < n - 1; i++)
            {
                var c = new List<long>();
                for (int j = 0; j < b.Count() - 1; j++)
                {
                    c.Add(b[j] + b[j + 1] - a[j + 1]);
                    if (b[j] + b[j + 1] - a[j + 1] == 0) ans++;
                }
                a = new List<long>(b);
                b = new List<long>(c);
            }
            Console.WriteLine(ans);
        }
    }
}