#include <bits/stdc++.h>
using namespace std;
long long int m;
long long int mul(long long int a, long long int b) {
  return (1LL * a * b) % m;
}
int main() {
  long long int i, j, n, arr[1000000], product = 1, sum = 0;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
  }
  if (n <= m) {
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j++) {
        product = mul(product, abs(arr[i] - arr[j])) % m;
      }
    }
  } else
    sum = 1;
  if (sum == 1)
    cout << 0;
  else
    cout << product % m;
  return 0;
}
