#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
class CKuroniAndImpossibleCalculation {
 public:
  void solve(std::istream& in, std::ostream& out) {
    int n, m;
    in >> n >> m;
    vector<int> a(n);
    for (long long i = (0); i < (n); i++) in >> a[i];
    sort((a).begin(), (a).end());
    unordered_map<int, int> cnt;
    vector<vector<int>> powerMod(m);
    for (long long i = (0); i < (m); i++) {
      powerMod[i].push_back(i % m);
      for (long long j = (1); j < (m); j++) {
        int next = powerMod[i][j - 1] * i % m;
        if (next == powerMod[i].front()) break;
        powerMod[i].push_back(next);
      }
    }
    int answer = 1;
    for (long long i = (0); i < (n); i++) {
      const int k = a[i] % m;
      for (const auto& p : cnt) {
        int j = p.first;
        int num = p.second;
        const int l = (k - j + m) % m;
        answer *=
            powerMod[l][(num + powerMod[j].size() - 1) % powerMod[j].size()];
        answer %= m;
      }
      cnt[k]++;
      if (answer == 0) break;
    }
    out << answer << endl;
  }
};
signed main() {
  CKuroniAndImpossibleCalculation solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
