#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int m;
const int N = 1e3 + 3;
bool u[N];
int t[N][N];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n >> m;
  vector<int> a(n);
  for (auto &_ : a) cin >> _;
  for (int i = 0; i < m; ++i)
    for (int j = 0; j < m; ++j) t[i][j] = i * j % m;
  sort(begin(a), end(a));
  int res = 1, h = 0;
  for (int i = 1; i < n; ++i) {
    u[h] = 1;
    int d = (a[i] - a[i - 1]) % m;
    h -= d;
    if (h < 0) h += m;
    for (int x = h; x < m; ++x)
      if (u[x]) res = t[res][(x - h)];
    for (int x = 0; x < h; ++x)
      if (u[x]) res = t[res][(x - h + m)];
  }
  cout << res << endl;
  return 0;
}
