#include <bits/stdc++.h>
using namespace std;
const long long N = 5005;
long long n, m, k, a[1000005], mo, Max, p[1000005], opt, g[N][N], jie[1000005],
    dp[2][N], cnt;
long long read() {
  long long sum = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    sum = sum * 10 + ch - '0';
    ch = getchar();
  }
  return sum;
}
signed main() {
  n = read();
  m = read();
  mo = read();
  for (long long i = 1; i <= n; i++) a[i] = read(), Max = max(Max, a[i]);
  jie[0] = 1;
  for (long long i = 1; i <= m; i++) jie[i] = 1ll * jie[i - 1] * i % mo;
  g[0][0] = 1;
  for (long long i = 1; i <= Max; i++)
    for (long long j = 1; j <= i; j++)
      g[i][j] = (1ll * g[i - 1][j] * (j - 1) % mo + g[i - 1][j - 1]) % mo;
  p[1] = m;
  for (long long i = 2; i <= m; i++) p[i] = 1ll * p[i - 1] * (m - i + 1) % mo;
  opt = 1;
  for (long long i = 1; i <= n; i++) {
    cnt = i & 1;
    memset(dp[cnt], 0, sizeof(dp[cnt]));
    for (long long j = 1; j <= min(m, a[i]); j++)
      dp[cnt][j] = (1ll * p[j] * opt % mo * g[a[i]][j] % mo -
                    1ll * g[a[i]][j] * jie[j] % mo * dp[1 - cnt][j] % mo + mo) %
                   mo;
    opt = 0;
    for (long long j = 1; j <= min(m, a[i]); j++) opt = (opt + dp[cnt][j]) % mo;
  }
  printf("%I64d\n", opt);
  return 0;
}
