#include<bits/stdc++.h>
using namespace std;
int main() {
	int N,M;
	cin>>N>>M;
	unordered_map<int,long> X;
	int A;
	int sum=0;
	long long total = 0;
	for(int i=0;i<N;i++){
		cin>>A;
		sum=(sum+A)%M;
		if(X.find(sum)!=X.end()){
			X[sum]++;
		}else{
			X[sum]=1;
		}
		if(sum%M==0)total++;
	}
	for(auto pair:X){
		total+=pair.second*(pair.second - 1)/2;
	}
	cout<<total<<endl;
}