#include <bits/stdc++.h>
using namespace std;
const int MAX_VAL = 5e3 + 2;
const int N = 1e6 + 10;
int n, m, BASE;
int P[N], cnt[N];
bool had[N];
int sum[2], fact[MAX_VAL];
int comb[MAX_VAL];
int dp[2][MAX_VAL], f[MAX_VAL][MAX_VAL];
inline void Add(int &a, int b) {
  a += b;
  if (a >= BASE) a -= BASE;
  if (a < 0) a += BASE;
}
inline int Mul(int a, int b) { return 1LL * a * b % BASE; }
void Factorize(int n, int sign, set<int> &primes) {
  while (n > 1) {
    int d = P[n], c = 0;
    while (n % d == 0) {
      n /= d;
      ++c;
    }
    cnt[d] += sign * c;
    if (cnt[d] == 0) {
      primes.erase(d);
    } else {
      primes.insert(d);
    }
  }
}
int Power(int a, int p) {
  int ans = 1;
  while (p) {
    if (p & 1) ans = 1LL * ans * a % BASE;
    a = 1LL * a * a % BASE;
    p >>= 1;
  }
  return ans;
}
void Sieve() {
  for (int i = 2; i < N; ++i)
    if (P[i] == 0) {
      P[i] = i;
      for (int j = 2 * i; j < N; j += i)
        if (P[j] == 0) P[j] = i;
    }
  set<int> primes;
  comb[0] = 1;
  Factorize(m, +1, primes);
  for (int i = 1; i < MAX_VAL; ++i) {
    if (i > m) break;
    comb[i] = 1;
    for (set<int>::iterator it = primes.begin(); it != primes.end(); ++it) {
      comb[i] = Mul(comb[i], Power(*it, cnt[*it]));
    }
    Factorize(m - i, +1, primes);
    Factorize(i + 1, -1, primes);
  }
}
inline int Color(int col, int len) { return Mul(fact[col], f[col][len]); }
int main() {
  cin >> n >> m >> BASE;
  Sieve();
  fact[0] = 1;
  for (int i = 1; i < MAX_VAL; ++i) {
    fact[i] = 1LL * fact[i - 1] * i % BASE;
  }
  int x = 0, y = 1;
  int l;
  cin >> l;
  f[0][0] = 1;
  for (int i = 1; i < MAX_VAL; ++i) {
    for (int j = i; j < MAX_VAL; ++j) {
      Add(f[i][j], Mul(f[i][j - 1], i - 1));
      Add(f[i][j], f[i - 1][j - 1]);
    }
  }
  for (int i = 1; i <= l; ++i) {
    dp[x][i] = Mul(comb[i], Color(i, l));
    Add(sum[x], dp[x][i]);
  }
  int pre_l = l;
  for (int k = 2; k <= n; ++k) {
    int l;
    cin >> l;
    for (int i = 1; i <= l; ++i) {
      dp[y][i] = Mul(Mul(sum[x], comb[i]), Color(i, l));
      Add(dp[y][i], -Mul(dp[x][i], Color(i, l)));
      Add(sum[y], dp[y][i]);
    }
    x ^= 1;
    y ^= 1;
    for (int i = 1; i <= pre_l; ++i) dp[y][i] = 0;
    sum[y] = 0;
    pre_l = l;
  }
  cout << sum[x] << endl;
  return 0;
}
