#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int n,m;cin>>n>>m;
	int a=0ll,b=0ll;
	map<int,int>re;
	re[0]++;
	for(int i=0;i<n;i++){
		cin>>a; b+=a;b=(b%m);re[b]++;
}
	int ans=0ll;
	for(auto&& w:re)ans+=w.second*(w.second-1)/2;
	cout<<ans<<endl;
}
