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 sum = 0;
			Dictionary<long, int> count = new Dictionary<long, int>();
			count.Add(0, 1);
			for (int i = 0; i < n; i++) {
				sum += a[i];
				long key = sum % m;
				if (!count.ContainsKey(key)) {
					count.Add(key, 0);
				}
				count[key]++;
			}
			//foreach (var item in count.OrderBy(p => p.Key)) {
			//	System.Diagnostics.Debug.WriteLine(item);
			//}
			long ans = 0;
			foreach (var c in count.Values) {
				ans += c * (c - 1) / 2;
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}
