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

int main(){
	long long n,m;
	cin>>n>>m;
	long long A[n+1],B[n+1],C[m]={},ans=0;
	A[0]=B[0]=0;
	for(long long i=1;i<=n;i++){
		cin>>A[i];
		B[i]=B[i-1]+A[i];
		B[i]=B[i]%m;
		C[B[i]]++;
	}
	ans+=C[0];
	for(long long i=0;i<m;i++){
		ans+=C[i]*(C[i]-1)/2;
	}
	cout<<ans;
	return 0;
}
