#include<iostream>
#include<map>
using namespace std;
int n;
long m,a[1<<17];
map<long,int>M;
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	M[0]++;
	long ans=0,sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		sum%=m;
		ans+=M[sum]++;
	}
	cout<<ans<<endl;
}
