#include <bits/stdc++.h>
using namespace std;
const int oo = 0x3f3f3f3f;
const double eps = 1e-9;
long long MOD;
int MOD_, LAY, LAM;
long long dp[5100][5100];
long long sum[5100];
long long fac[1000100];
int over[5100];
int ctp[5100];
long long powMod(long long m, int p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = (r * m) % MOD;
    m = (m * m) % MOD;
    p = p >> 1;
  }
  return r;
}
int tei[1000100];
long long resu[5100];
long long resu_[5100];
int main() {
  for (int i = (0); i < (1000100); i++) tei[i] = i;
  for (int i = (2); i < (1000100); i++) {
    if (tei[i] == i) {
      int j = i;
      while (j < 1000100) {
        tei[j] = i;
        j += i;
      }
    }
  }
  scanf("%d%d%d", &LAY, &LAM, &MOD_);
  MOD = MOD_;
  fac[0] = 1;
  for (int i = (1); i < (1000100); i++) fac[i] = (i * fac[i - 1]) % MOD;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  dp[1][1] = 1;
  for (int i = (1); i < (5001); i++) {
    for (int j = (1); j < (5001); j++)
      if (dp[i][j]) {
        dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (j - 1)) % MOD;
        dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;
        if (j > LAM) dp[i][j] = 0;
      }
  }
  for (int i = (0); i < (5001); i++) {
    for (int j = (0); j < (5001); j++) {
      dp[i][j] = (dp[i][j] * fac[j]) % MOD;
    }
  }
  over[0] = 1;
  long long mul = 1;
  for (int i = (0); i < (5001); i++) ctp[i] = 0;
  for (int i = (1); i < (min(LAM + 1, 5001)); i++) {
    int c = i;
    while (c != 1) {
      ctp[tei[c]]--;
      c /= tei[c];
    }
    c = LAM - i + 1;
    while (c != 1) {
      if (tei[c] < 5000) {
        ctp[tei[c]]++;
      } else {
        mul = (mul * tei[c]) % MOD;
      }
      c /= tei[c];
    }
    over[i] = mul;
    for (int j = (0); j < (5000); j++)
      if (ctp[j]) over[i] = (over[i] * powMod(j, ctp[j])) % MOD;
  }
  for (int i = (0); i < (5050); i++) {
    sum[i] = 0;
    for (int j = (0); j < (5050); j++) {
      sum[i] += dp[i][j];
    }
    sum[i] %= MOD;
  }
  memset(resu, 0, sizeof(resu));
  resu[0] = 1;
  long long rsum = 1;
  int last = 0;
  for (int ii = (0); ii < (LAY); ii++) {
    int next;
    scanf("%d", &next);
    for (int i = (0); i < (next + 1); i++) {
      if (i > last) resu[i] = 0;
      resu_[i] = (((rsum * over[i]) % MOD) * dp[next][i]) % MOD;
      resu_[i] -= resu[i] * dp[next][i];
      resu_[i] %= MOD;
    }
    last = next;
    rsum = 0;
    for (int i = (0); i < (next + 1); i++) resu[i] = resu_[i];
    for (int i = (0); i < (next + 1); i++) rsum += resu[i];
    rsum %= MOD;
  }
  if (rsum < 0) rsum += MOD;
  cout << rsum << endl;
  return 0;
}
