#include <bits/stdc++.h>
using namespace std;
int n, m, MOD, l[1000009];
int S[5009][5009], S2[5009][5009];
long long dp[2][5005], sum, tmp, fact[5009], A[5009];
inline void add(long long &x, long long y) {
  x += y;
  if (x >= MOD) x -= MOD;
  if (x < 0) x += MOD;
}
int main() {
  scanf("%d%d%d", &n, &m, &MOD);
  for (int i = 1; i <= n; i++) scanf("%d", &l[i]);
  for (int i = 0; i < 5009; i++) {
    S2[i][0] = 0;
    S2[i][i] = 1;
    for (int j = 1; j < i; j++)
      S2[i][j] = (1LL * S2[i - 1][j] * (j - 1) + S2[i - 1][j - 1]) % MOD;
  }
  A[0] = 1;
  for (int i = 1; i < 5009; i++) A[i] = A[i - 1] * (m + 1 - i) % MOD;
  for (int i = 0; i < 5009; i++) {
    for (int j = 0; j <= i; j++) S[i][j] = S2[i][j] * A[j] % MOD;
  }
  fact[0] = 1;
  for (int i = 1; i < 5009; i++) fact[i] = fact[i - 1] * i % MOD;
  int cur = 0;
  dp[0][0] = 1;
  sum = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= l[i]; j++) dp[cur ^ 1][j] = 0;
    tmp = 0;
    for (int j = 2 - (l[i] == 1); j <= l[i]; j++) {
      add(dp[cur ^ 1][j], sum * S[l[i]][j] % MOD);
      if (j <= l[i - 1]) {
        add(dp[cur ^ 1][j], -dp[cur][j] * fact[j] % MOD * S2[l[i]][j] % MOD);
      }
      add(tmp, dp[cur ^ 1][j]);
    }
    sum = tmp;
    cur ^= 1;
  }
  cout << sum << endl;
  return 0;
}
