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

long long n,m,A[100001],ans=0;
map<long long, long long> M;

int main(){
	cin>>n>>m;
	A[0]=0;
	M[0]++;
	for(int i=1;i<=n;i++){
		cin>>A[i];
		A[i]+=A[i-1];
		M[A[i]%m]++;
	}
	for(pair<long long, long long> cnt : M){
		ans+=cnt.second*(cnt.second-(long long)1)/(long long)2;
	}
	cout<<ans<<endl;
}