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

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//long n = long.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
			long ans = 0, sum = 0;
			for (int i = 0; i < n; i++) {
				sum = 0;
				for (int j = i; j < n; j++) {
					sum += a[j];
					if (sum % m == 0) {
						ans++;
					}
					//System.Diagnostics.Debug.WriteLine($"a[{i}] - a[{j}] {sum}");
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

	}
}
