#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a, ans = 0;
  map<long long, long long> mp;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    mp[a % m]++;
  }
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    ans += itr->second * (itr->second - 1) / 2;
  }
  cout << ans;
  return 0;
}
