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[400000000];
		long[]B2 = new long[400000000];
		long[]B3 = new long[400000000];
		B[0] = 1;
		long ans = 0;
		long ct = 0;
		for(var i=0;i<N;i++){
			ct += A[i];
			ct = ct % M;
			if(ct >= 800000000){
				ans += B3[ct];
				B3[ct] += 1;
			} else if(ct >= 400000000){
				ans += B2[ct];
				B2[ct] += 1;
			} else {
				ans += B[ct];
				B[ct] += 1;
			}
		}
		Console.WriteLine(ans);
	}
}