#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
long long n, m, a[N];
int tmp[N];
int main() {
  while (cin >> n >> m) {
    int flag = 0;
    memset(tmp, 0, sizeof(tmp));
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      tmp[a[i] % m]++;
      if (tmp[a[i] % m] >= 2) flag = 1;
    }
    if (flag)
      puts("0");
    else {
      long long ans = 1;
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= i - 1; j++) {
          (ans *= abs(a[i] - a[j])) %= m;
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}
