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

namespace CandyDistribution
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n_m = Console.ReadLine().Split(' ');
            var n = int.Parse(n_m[0]);
            var m = int.Parse(n_m[1]);
            var boxes = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var hitDict = new Dictionary<long,long>();
            var hit = 0L;
            for(var l = 0; l < boxes.Count;l++)
            {
                var sum = 0L;
                for (var r = l; r < boxes.Count; r++)
                {
                    sum += boxes[r];
                    if (hitDict.ContainsKey(sum)) {
                        hitDict[sum]++;
                    } else
                    {
                        hitDict.Add(sum, 1L);
                    }
                }
            }
            
            foreach (long key in hitDict.Keys)
            {
                if (key%m == 0)
                {
                    hit += hitDict[key];
                }
            }
            Console.Write(hit);
        }
    }
}
