#include<algorithm>
#include<cstdio>
#include<map>
#include<iostream>
using namespace std;
int sum;
int a[100005];
int n,m;
map<int,int> cnt,vis;
long long ans;
int main() {
	cin>>n>>m;
	cnt[0]=1;
	for(int i=1;i<=n;i++) {
		cin>>a[i],sum=(sum+a[i]%m)%m;
		if(cnt[sum]>=1) ans+=cnt[sum];
		cnt[sum]++;
	}
	cout<<ans<<"\n";
}
