#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i,a,b) for(int i=a;i<=b;i++)
int n,m;
LL sum,ans;
map<LL,LL>mp;
int main()
{
	cin>>n>>m;
	int t;
	rep(i,1,n)
	{
		cin>>t;
		sum+=t;
		sum%=m;
		mp[sum]++;
	}
	for(auto i:mp)
	{
		LL f=i.first;
		LL s=i.second;
	    if(f==0)ans+=s*(s+1)/2;
	    else ans+=s*(s-1)/2;
	}
	cout<<ans;

}
