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 ans = 0;
		long ct = 0;
		string[] str2 = Console.ReadLine().Split();
		long[]clist = new long[1];
		long[]B0 = new long[100001];
		clist[0] = 0;
		B0[0] = 1;
		for(var i=0;i<N;i++){
			ct = (ct + long.Parse(str2[i])) % M;
			int num = Array.IndexOf(clist, ct);
			if(num >= 0){
				ans += B0[num];
				B0[num] += 1;
			} else {
				Array.Resize(ref clist, clist.Length + 1);
				B0[clist.Length-1] = 1;
				clist[clist.Length-1] = ct;
			}
		}
		Console.WriteLine(ans);
	}
}