using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long M = long.Parse(str[1]);
		long[]A = new long[N];
		string[] str2 = Console.ReadLine().Split();
		for(var i=0;i<N;i++){
			A[i] = long.Parse(str2[i]) % M;
		}
		long[]B = new long[M];
		B[0] = 1;
		long ans = 0;
		long ct = 0;
		for(var i=0;i<N;i++){
			ct += A[i];
			ct = ct % M;
			ans += B[ct];
			B[ct] += 1;
		}
		Console.WriteLine(ans);
	}
}