#include <bits/stdc++.h>
#define int long long
using namespace std;

const int Max=100010;
int n,m,num[Max],pre,ans;
map<int,int>sum;

signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&num[i]);
	sum[0]=1;
	for(int i=1;i<=n;i++)
	{
	  int x=num[i]+pre;
	  pre=x;
	  ans+=sum[x%m];
	  sum[x%m]++;
	}
	cout<<ans<<"\n";

	return 0;
}