#include <bits/stdc++.h>
using namespace std;
int n, m;
int Pow(int b, long long p) {
  if (!p) return 1;
  int z = Pow(b, p / 2);
  if (p & 1) return z * z * b % m;
  return z * z % m;
}
int main() {
  cin >> n >> m;
  vector<int> v(n);
  for (auto &x : v) scanf("%d", &x);
  sort(v.begin(), v.end());
  int f[1000] = {};
  long long res[1000] = {};
  for (int i = 0; i < n; ++i) {
    int y = v[i] % m;
    for (int x = 0; x < m; ++x) {
      int z = y - x;
      if (z < 0) z += m;
      res[z] += f[x];
    }
    ++f[y];
  }
  int r = 1;
  for (int i = 0; i < m; ++i) r = r * Pow(i, res[i]) % m;
  cout << r << endl;
  return 0;
}
