#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m,ans;
map<int,int> x;
int main(){
	cin >> n >> m;
	ll a[n];
	x[0]=1;
	cin >> a[0];
	for(int i=1;i<n;i++){
		cin >> a[i];
		a[i]+=a[i-1];
	}
	for(int i=0;i<n;i++){
		ans+=x[a[i]%m];
		x[a[i]%m]++;
	}
	cout << ans;
	return 0;
}