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

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Player
{
    static void Main(string[] args)
    {
        string[] a = Console.ReadLine().Split(' ');

        int BoxCount = int.Parse(a[0]);
        int ChildrenCount = int.Parse(a[1]);
        ulong[] arrBox = Array.ConvertAll(Console.ReadLine().Split(' '),
                                                    delegate (string value) {
                                                        return ulong.Parse(value);
                                                    });
        ulong[] lSumsMemo = new ulong[arrBox.Length];
        ulong Pattern = 0;

        for(int i = 0; i < arrBox.Length; i++)
        {
            ulong Sum = 0;
            for(int j = i; j < arrBox.Length; j++)
            {
                Sum += arrBox[j];
            }

            lSumsMemo[i] = Sum;

            if(Sum % (ulong)ChildrenCount == 0)
            {
                Pattern++;
            }
        }

        ulong[] fSumsMemo = new ulong[arrBox.Length];

        for (int i = arrBox.Length - 1; i > 0; i--)
        {
            ulong Sum = 0;
            for (int j = 0; j < i; j++)
            {
                Sum += arrBox[j];
            }

            fSumsMemo[i] = Sum;

            if (Sum % (ulong)ChildrenCount == 0)
            {
                Pattern++;
            }
        }

        for (int i = 1; i < arrBox.Length - 1; i++)
        {
            for(int j = i; j < arrBox.Length - 1; j++)
            {
                if(fSumsMemo[i] - lSumsMemo[j] % (ulong)ChildrenCount == 0)
                {
                    Pattern++;
                }
            }
        }
        Console.WriteLine(Pattern);
    }
}