using System;
using System.Linq;

namespace ABC105_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var N = NM[0];
            var M = NM[1];
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var asum = new long[N];
            asum[0] = a[0];
            for (int i = 1; i < N; i++)
                asum[i] = a[i] + asum[i - 1];

            var cnt = 0;
            for (int i = 0; i < N; i++)
                for (int j = 0; j < N; j++)
                {
                    if (i == j && asum[i] % M == 0)
                        cnt++;
                    else if (asum[i] - asum[j] > 0 && (asum[i] - asum[j]) % M == 0)
                        cnt++;
                }

            Console.WriteLine(cnt   );
        }
    }
}
