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


int main(){
  int N, M;cin>>N>>M;
  map<ll, ll> counter;
  for (int i=0;i<N;++i){
    ll a;cin>>a;
    map[a%M]++;
  }

  int L=counter.size();
  ll ans=0;
  for (int p:counter){
    ll c=p.second;
    ans+=(c*(c-1))/2;
  }

  ans+=counter[0];
  
  cout << ans << endl;
  return 0;
}