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

namespace AtCoderCs
{
    class Program
    {
        static void Main()
        {

            var Arg = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var Candies = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var Sum = Candies.Sum();
            var Result = 0;

            Arg[0]--;

            for (long i = 0; i < Arg[0]; i++)
            {

                for (long j = Arg[0], Compare = Sum; i < j; j--)
                {

                    if (Compare % Arg[1] == 0) Result++;

                    Compare -= Candies[j];

                }

                Sum -= Candies[i];

            }

            Console.WriteLine(Result);

        }


    }
}
