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);
            var a = Enumerable.Repeat((long)0, b.Count()).ToArray();
            long ans = 0;
            int max = b.Count() - 1;
            for (int i = 0; i < n - 1; i++)
            {
                var c = new long[max + 1];
                for (int j = 0; j < max; j++)
                {
                    c[j] = b[j] + b[j + 1] - a[j + 1];
                    if (b[j] + b[j + 1] - a[j + 1] == 0) ans++;
                }
                max--;
                b.CopyTo(a, 0);
                c.CopyTo(b, 0);
            }
            Console.WriteLine(ans);
        }
    }
}