#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
	ll n,m;cin>>n>>m;
	
	ll a[n];
	
	unordered_map<ll,ll>rem;
	
	ll sum=0;
	
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum+=a[i];sum=sum%m;
		rem[sum%m]++;
	}
	
	/*for(int i=0;i<m;i++){
		cout<<rem[i]<<" "<<endl;
	}*/
	
	ll ans=0;
	
	map<ll,ll>::iterator it=rem.begin();
	
	for(;it!=rem.end();it++){
		//cout<<(*it).first<<" "<<(*it).second<<endl;
		
		if((*it).first==0){
			ans+=(*it).second;
		}
		
		ans+=(((*it).second)*((*it).second-1))/2;
		//cout<<ans<<endl;
	}
	
	cout<<ans<<endl;
	return 0;
}