#include <bits/stdc++.h>
bool FLAG = 0;
using namespace std;
const long long MOD = (long long)1e9 + 7, N = (long long)2e6 + 222;
const long long INF = (long long)1e18;
long long n, m, a[N], b[N], used[N], was[N];
;
void solve() {
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  if (n >= 1000) {
    cout << 0;
    return;
  }
  long long ans = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = i + 1; j <= n; ++j) {
      ans *= (a[j] - a[i]) % m;
      ans %= m;
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
