#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n,m;
	cin>>n>>m;
	map<int,int> dp;
	dp[0] = 1;
	int cnt = 0;
	ll res = 0;
	for(int i = 0; i < n; i++){
		int t;cin>>t;
		cnt+=t;
		cnt%=m;
		res+=dp[cnt]++;
	}
	cout<<res;
}


