#include <bits/stdc++.h>
using namespace std;
const int MAXL = 5e3 + 20, MAXN = 1e6 + 10;
int MOD;
inline int add(int a, int b) {
  return ((long long)a + (long long)b + MOD) % MOD;
}
inline int mul(int a, int b) {
  return ((long long)a * (long long)b + MOD) % MOD;
}
int fact[MAXN];
int col[MAXL][MAXL], col2[MAXL][MAXL], l[MAXN], n, m, dp[2][MAXL];
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  cin >> n >> m >> MOD;
  for (int i = 0; i < n; i++) cin >> l[i];
  fact[0] = 1 % MOD;
  for (int i = 1; i < MAXN; i++) fact[i] = mul(fact[i - 1], i);
  col[0][0] = 1 % MOD;
  for (int i = 1; i < MAXL; i++)
    for (int j = 1; j < MAXL; j++)
      col[i][j] =
          add(mul(col[i - 1][j], j - 1), mul(col[i - 1][j - 1], m - j + 1));
  col2[0][0] = 1 % MOD;
  for (int i = 1; i < MAXL; i++)
    for (int j = 1; j < MAXL; j++)
      col2[i][j] = add(mul(col2[i - 1][j], j - 1), col2[i - 1][j - 1]);
  for (int i = 1; i <= l[0]; i++) dp[0][i] = col[l[0]][i];
  for (int i = 1; i < n; i++) {
    int cur = i % 2, pre = 1 - cur;
    for (int j = 0; j <= l[i]; j++) dp[cur][j] = 0;
    int sum = 0;
    for (int j = 0; j <= l[i - 1]; j++) sum = add(sum, dp[pre][j]);
    for (int j = 1; j <= l[i]; j++) {
      dp[cur][j] = mul(sum, col[l[i]][j]);
      if (j <= l[i - 1]) {
        int x = mul(col2[l[i]][j], fact[j]);
        dp[cur][j] = add(dp[cur][j], -mul(dp[pre][j], x));
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= l[n - 1]; i++) ans = add(ans, dp[(n + 1) % 2][i]);
  cout << ans << endl;
}
