#include <bits/stdc++.h>
using namespace std;
int read() {
  int res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) res = (res << 3) + (res << 1) + (c ^ 48), c = getchar();
  return res * f;
}
const int maxn = 2e5 + 10;
const int maxm = 1e3 + 10;
int n, m, a[maxn], tmp[maxm], ct[maxm];
int qpow(int x, int p) {
  int res = 1;
  for (; p; x = (x * x) % m, p >>= 1)
    if (p & 1) res = (res * x) % m;
  return res;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  if (n >= 20000) {
    printf("0\n");
    return 0;
  }
  sort(a + 1, a + n + 1);
  for (int i = 2; i <= n; i++) {
    int x = (a[i] - a[1]) % m;
    tmp[x]++;
    ct[x]++;
  }
  for (int i = 2; i < n; i++) {
    int x = (a[i] - a[1]) % m;
    tmp[x]--;
    for (int j = 0; j < m; j++) ct[j] += tmp[(j + x) % m];
  }
  int ans = 1;
  for (int i = 0; i < m; i++) ans = (ans * qpow(i, ct[i])) % m;
  printf("%d\n", ans);
  return 0;
}
