#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

#include<unordered_map>

int main(){
	int N;
	LL M;
	cin >> N >> M;
	map<LL, LL> mp;
	LL sum = 0;
	mp[0]++;
	LL ans = 0;
	for(int i=0; i<N; i++){
		LL a;
		cin >> a;
		sum += a;
		ans += mp[sum%M];
		mp[sum%M]++;
	}
	cout << ans << endl;
}