#include <bits/stdc++.h>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int, int>>>;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long ceil(const long long a, const long long b) { return (a + b - 1) / b; }
int main() {
  long long n, m;
  cin >> n >> m;
  map<long long, long long> cnt;
  for (int i = 0; i < (n); ++i) {
    long long tmp;
    cin >> tmp;
    tmp %= m;
    cnt[tmp]++;
  }
  long long ans = 0;
  for (auto i : cnt) {
    if (i.second >= 2) {
      ans += (i.second * (i.second - 1)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}
