using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

    public void Proc()
    {
        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.BoxCount = (int)inpt[0];
        this.ChildCount = inpt[1];

        this.Box = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        this.BoxWa = new long[BoxCount];


        this.BoxWa[0] = this.Box[0];

        for (int i = 1; i < this.BoxCount; i++) {
            this.BoxWa[i] = this.BoxWa[i - 1] + this.Box[i];
        }
        long ans = 0;



        for (int i = 0; i < this.BoxCount; i++) {
            ans += GetAns(i, 0);
        }

        Console.WriteLine(ans);

    }

    private Dictionary<long, Dictionary<long, long>> dic = new Dictionary<long, Dictionary<long, long>>();
    private long GetAns(int idx, long remain) {
        if(idx >= this.Box.Length) {
            return 0;
        }
        if(!dic.ContainsKey(idx)) {
            dic.Add(idx, new Dictionary<long, long>());
        }
        if(dic[idx].ContainsKey(remain)) {
            return dic[idx][remain];
        }
        long subTotal = remain + this.Box[idx];
        subTotal = subTotal % ChildCount;

        long ans = 0;
        if(subTotal == 0) {
            ans++;
        }

        ans += GetAns(idx + 1, subTotal);
        dic[idx][remain] = ans;
        return ans;
    }

    int BoxCount;
    long ChildCount;

    long[] Box;
    long[] BoxWa;

    public class Reader
    {
        static StringReader sr;
        public static bool IsDebug = false;
        public static string ReadLine()
        {
            if (IsDebug)
            {
                if (sr == null)
                {
                    sr = new StringReader(InputText.Trim());
                }
                return sr.ReadLine();
            }
            else
            {
                return Console.ReadLine();
            }
        }
        private static string InputText = @"


13 17
29 7 5 7 9 51 7 13 8 55 42 9 81

";
    }

    public static void Main(string[] args)
    {
#if DEBUG
        Reader.IsDebug = true;
#endif
        Program prg = new Program();
        prg.Proc();
    }
}
