using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var A = G;
		var sum = new long[N + 1];
		for (var i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
		var c = new Dictionary<long, int>();
		foreach (var a in sum.Select(a => a % M))
			if (!c.ContainsKey(a)) c[a] = 1;
			else c[a]++;
		var ans = 0L;
		foreach (var v in c.Values) ans += v * (v - 1L) / 2;
		WriteLine(ans);
	}
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		int N = I[0], M = I[1];
		var A = G;
		var sum = new long[N + 1];
		for (var i = 0; i < N; i++) sum[i + 1] = sum[i] + A[i];
		var c = new Dictionary<long, int>();
		foreach (var a in sum.Select(a => a % M))
			if (!c.ContainsKey(a)) c[a] = 1;
			else c[a]++;
		var ans = 0L;
		foreach (var v in c.Values) ans += v * (v - 1L) / 2;
		WriteLine(ans);
	}
}
