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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
			int n = (int)nm[0];
			long m = nm[1];
			long[] a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

			long[] sums = new long[n + 1];
			for (int i = 0; i < n; i++) {
				sums[i + 1] = (sums[i] + a[i]) % m;
			}

			var counts = new Dictionary<long, int>();
			for (int i = 0; i < n + 1; i++) {
				if (counts.ContainsKey(sums[i])) {
					counts[sums[i]]++;
				} else {
					counts[sums[i]] = 1;
				}
			}

			long ans = 0;
			foreach (var count in counts) {
				ans += (count.Value * (count.Value - 1) / 2);
			}

			Console.WriteLine(ans);
		}
	}
}
