#include <bits/stdc++.h>
using namespace std;
long long n, m, p, ma, l[1000010], f[5010][5010], fac[1000010], g[1000010],
    dp[2][5010];
signed main() {
  scanf("%lld%lld%lld", &n, &m, &p);
  for (long long i = 1; i <= n; i++) scanf("%lld", &l[i]), ma = max(ma, l[i]);
  f[1][1] = fac[0] = g[0] = dp[0][0] = 1;
  for (long long i = 2; i <= ma; i++)
    for (long long j = 1; j <= min(i, m); j++)
      f[i][j] = (f[i - 1][j - 1] + f[i - 1][j] * (j - 1) % p) % p;
  for (long long i = 1; i <= m; i++)
    fac[i] = fac[i - 1] * i % p, g[i] = g[i - 1] * (m - i + 1) % p;
  for (long long i = 1; i <= n; i++) {
    memset(dp[i & 1], 0, sizeof(dp[i & 1]));
    for (long long j = 1; j <= l[i]; j++) {
      dp[i & 1][j] = f[l[i]][j] * g[j] % p * dp[(i - 1) & 1][0] % p -
                     f[l[i]][j] * fac[j] % p * dp[(i - 1) & 1][j] % p;
      dp[i & 1][0] = (dp[i & 1][0] + dp[i & 1][j]) % p;
    }
  }
  printf("%lld", (dp[n & 1][0] + p) % p);
  return 0;
}
