using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        var sp = ReadLine().Split();
        int m = Parse(sp[1]);
        sp = ReadLine().Split();
        Dictionary<int, int> dic = new Dictionary<int, int>() { { 0, 1 } };
        int amari = 0;
        foreach(var str in sp)
        {
            amari += Parse(str);
            amari %= m;
            if (dic.ContainsKey(amari)) ++dic[amari];
            else dic[amari] = 1;
        }
        long result = 0;
        foreach(var count in dic.Values.Where(c => 1 < c))
        {
            result += count * (count - 1) / 2;
        }
        WriteLine(result);
    }

//    static string ReadLine()
//    {
//        return _inputs[_inIndex++];
//    }

//    static string[] _inputs = @"10 400000000
//1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000".Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

//    static int _inIndex = 0;
}

