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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var m = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var w = Array.ConvertAll(line, int.Parse);
        var a = new long[n];
        var d = new Dictionary<long, int>();
        a[0] = w[0];
        d[a[0] % m] = 1;
        if (d.ContainsKey(0)) d[0]++;
        else d[0] = 1;
        for (int i = 1; i < n; i++)
        {
            a[i] = a[i - 1] + w[i];
            var k = a[i] % m;
            if (d.ContainsKey(k)) d[k]++;
            else d[k] = 1;
        }
        Console.WriteLine(getAns(d));
    }
    public static long getAns(Dictionary<long, int> d)
    {
        var ret = 0L;
        foreach (var x in d.Where(y => y.Value >= 2))
            ret += (x.Value * (x.Value - 1)) / 2L;
        return ret;
    }
}
