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

int main() {
	// your code goes here
	int n,d;
	cin>>n>>d;
	
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin>>v[i];
	}
	
	unordered_map<int,int> ump;
	int cnt = 0;
	
	for(int k = 0; k < n; k++){
		
		// Sometimes v[k] is greater then k then if we did not perform this step which 
		// leads to end up -ve numbers
		
		int ele = v[k] % d;
		
		int rem = (d - ele) % d;
		
		if(ump.count(rem)){
			cnt += ump[rem];
		}
		
		// ump[v[i] % d] ++;
		for(int u = 0; u <= k-1; u++){
			ump[(v[u] + v[k]) % d]++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}