#include <bits/stdc++.h>
using namespace std;
int dp[5005][5005];
int dp2[5005][5005];
int MOD, n, m;
int layer[1000005];
int len[1000005];
int ans[1000005];
int all[10000005];
int main(void) {
  scanf("%d%d%d", &n, &m, &MOD);
  for (int i = 1; i <= n; i++) scanf("%d", &layer[i]);
  dp[1][1] = m;
  dp2[1][1] = 1;
  for (int i = 2; i <= 5000; i++) {
    dp[i][1] = 0;
    dp2[i][1] = 0;
    for (int j = 2; j <= i && j <= m; j++) {
      dp[i][j] = (dp[i - 1][j] * 1LL * (j - 1) +
                  dp[i - 1][j - 1] * 1LL * (m - j + 1)) %
                 MOD;
      dp2[i][j] = (dp2[i - 1][j] * 1LL * (j - 1) + dp2[i - 1][j - 1]) % MOD;
    }
  }
  int F[5000] = {};
  F[0] = 1;
  for (int i = 1; i <= 5000; i++) F[i] = F[i - 1] * 1LL * i % MOD;
  for (int i = 2; i <= 5000; i++)
    for (int j = 2; j <= i && j <= m; j++)
      dp2[i][j] = dp2[i][j] * 1LL * F[j] % MOD;
  for (int i = 1; i <= n; i++) len[i] = len[i - 1] + layer[i];
  ans[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= layer[i]; j++) {
      int target = len[i - 1] + j;
      all[target] = ans[i - 1] * 1LL * dp[layer[i]][j] % MOD;
      if (j <= layer[i - 1] && i - 2 >= 0)
        all[target] =
            (all[target] - all[len[i - 2] + j] * 1LL * dp2[layer[i]][j]) % MOD;
      ans[i] = (ans[i] + all[target]) % MOD;
    }
  }
  printf("%d\n", (ans[n] + MOD) % MOD);
  return 0;
}
