#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long sum,ans;
map<long long,long long>p;
int main(){
	cin>>n>>m;
	p[0]=1;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		sum+=x;
		sum%=m;
		ans+=p[sum]++;
	}
	cout<<ans<<endl;
	return 0;
}