using System;

namespace AGC023
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = Util.GetIntLine();
            int[] nums = Util.GetIntArray();

            int cnt = 0;
            //int sum = 0;
            //int sum2 = 0;
            int[] sums = new int[2];
            int[] cnts = new int[2];

            //for (int i = 0; i < nums.Length; i++)
            //{
            //    sums[i] += sums[i - 1] + nums[i];
            //    if (sum == 0)
            //    {
            //        cnts[i]++;
            //    }
            //}

            for (int i = 0; i < nums.Length; i+=2)
            {
                sums[0] = 0;
                sums[1] = 0;
                cnts[0] = 0;
                cnts[1] = 0;
                for (int j = i; j < nums.Length; j++)
                {
                    sums[0] += nums[j];
                    if (sums[0] == 0)
                    {
                        cnts[0]++;
                    }
                    if (j + 1 < nums.Length)
                    {
                        sums[1] += nums[j + 1];
                        if (sums[1] == 0)
                        {
                            cnts[1]++;
                        }
                    }
                }
                cnt += cnts[0] + cnts[1];
            }

            Console.WriteLine(cnt);
        }
    }

    class Util
    {
        public static int GetIntLine()
        {
            string lin = Console.ReadLine().Trim();

            return int.Parse(lin);
        }

        public static int[] GetIntArray()
        {
            string lin = Console.ReadLine().Trim();

            string[] ss = lin.Split();

            int[] ret = new int[ss.Length];

            for (int i = 0; i < ss.Length; i++)
            {
                ret[i] = int.Parse(ss[i]);
            }

            return ret;
        }
    }
}
