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



namespace CSharpSample01
{

    
      
    class Program
    {

        static int[] A;
        static int N;
        static long M;
        static long[] B;
        static Dictionary<long, int> dic;

        static void CreateB()
        {
            B = new long[N + 1];
            B[0] = 0;

            for(int i = 1; i <= N; i++)
            {
                B[i] = (long)B[i - 1] + A[i - 1];
            }

        }

        static void Createdic()
        {
            dic = new Dictionary<long, int>();

            for(int i = 0; i <= N; i++)
            {
                long amari = B[i] % M;
                if (!dic.ContainsKey(amari))
                {
                    dic[amari] = 1;
                }
                else
                {
                    dic[amari]++;
                }
            }

        }

        
        static long Solve()
        {
            long cnt = 0;

            foreach(var s in dic)
            {
                cnt += (long)(s.Value * (s.Value - 1)) / 2;
            }

            return cnt;
        }

        static void Main(string[] args)
        {
            //入力1(N, M)
            int[] input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            N = input[0];
            M = input[1];

            //入力2(A)
            A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            CreateB();
            //Console.WriteLine($"B:{string.Join(" ", B)}");
            Createdic();
            //foreach (var s in dic) Console.WriteLine($"余り:{s.Key} 個数:{s.Value}");

            Console.WriteLine(Solve());

        }
    }

}