using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dcs
{
    class Program
    {
        static void Main(string[] args)
        {
            var nm = Console.ReadLine().Split(' ').ToList().Select(x => Int32.Parse(x)).ToArray();
            var n = nm[0];
            var m = nm[1];

            var An = Console.ReadLine().Split(' ').Select(x=>Int32.Parse(x)).ToArray();

            //            Console.WriteLine(n+" "+m);


            var dict = new Dictionary<Int32,Int64>();

            dict.Add(0, 1);
            var accum = 0;
            foreach(var e in An)
            {
                accum += e;
                var r = accum %= m;

                if (dict.ContainsKey(r))
                    dict[r] += 1;
                else
                    dict.Add(r, 1);
            }
            
            /*
            foreach (var e in dict)
                Console.WriteLine(e);
            */

            var ans =
                dict.Select(x => x.Value)
                .Where(x => x > 1)
                .Select( x => x*(x-1)/2 )
                .Aggregate((a0, an) => a0+an );

/*
            foreach (var e in arr)
                Console.WriteLine(e);
*/
            Console.WriteLine(ans);
        }
    }
}
