#include <bits/stdc++.h>
using namespace std;
long long mod1k[1000];
int n, m;
int binpow(int base, int expe) {
  if (!expe) return 1;
  if (expe & 1)
    return (base * binpow(base, expe - 1)) % m;
  else {
    int r = binpow(base, expe >> 1);
    return (r * r) % m;
  }
}
int main(int argc, char** argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long invs = 0;
  std::cin >> n >> m;
  vector<int> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    int k = s[i];
    long long cur = k % m;
    for (int j = cur; j < m; j++) invs += mod1k[j];
    ++mod1k[cur];
    if (mod1k[cur] > 1) {
      cout << "0\n";
      return 0;
    }
  }
  int ans = 1;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < i; j++) {
      if (!mod1k[i] || !mod1k[j]) continue;
      ans = (ans * (i - j)) % m;
    }
  }
  if (ans == 0)
    cout << "0\n";
  else
    cout << (invs & 1 ? m - ans : ans) << '\n';
  return 0;
}
