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];

        long[] items = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();

        this.Box = new long[items.Length];
        for (int i = 0; i < items.Length; i++) {
            long num = items[i];
            if(i > 0) {
                num += this.Box[i - 1];
            }
            this.Box[i] = num;
            num = num % ChildCount;
            if(NumCount.ContainsKey(num)) {
                NumCount[num]++;
            } else {
                NumCount.Add(num, 1);
            }
        }

        long ans = 0;

        foreach(long key in NumCount.Keys) {
            long tmp = NumCount[key] * (NumCount[key] - 1) / 2;
            if(key == 0) {
                tmp = NumCount[key] * (NumCount[key] + 1) / 2;
            }
            ans += tmp;
        }
        Console.WriteLine(ans);
    }

    private Dictionary<long, int> NumCount = new Dictionary<long, int>();
    int BoxCount;
    long ChildCount;

    long[] Box;


    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();
    }
}
