using System;
using static System.Console;
using static System.Math;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Program
{
    static void Main()
    {
        var input = ReadLine().Split();
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
        var input1 = ReadLine().Split();
        int[] a = new int[n];
        foreach(int i in EnumerableCommon.Range(n))
        {
            a[i] = int.Parse(input1[i]);
        }

    long[] dp = new long[n+1];

        int count = 0;
        foreach(int i in EnumerableCommon.Range(n))
        {
            foreach(int j in EnumerableCommon.Range(n))
            {
                dp[j] = a[j];
                if (j >= i)
                {
                    if (j - 1 >= 0)
                    {
                        dp[j] = dp[j - 1] + a[j];
                    }
                    if (dp[j] != 0 && dp[j] % m == 0) count++;
                }
            }
        }
        WriteLine(count);

    }
    public static partial class EnumerableCommon
    {
        public static IEnumerable<int> Range(int count)
        {
            return Enumerable.Range(0, count);
        }
    }
}