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

namespace abc105_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long sum = 0;
            Dictionary<long, int> dic = new Dictionary<long, int>();
            dic[0] = 1;
            for (int i = 0; i < x[0]; i++)
            {
                sum += a[i]; sum %= x[1];
                if (!dic.ContainsKey(sum)) dic[sum] = 0;
                dic[sum]++;
            }
            long ret = 0;
            foreach (var item in dic)
            {
                ret += item.Value * (item.Value - 1) / 2;
            }
            Console.WriteLine(ret);
        }
    }
}