#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 100;
int n, m;
long long mod;
int len[1000000 + 100];
long long res[1000000 + 100];
long long fac[maxn];
long long num[maxn][maxn];
long long A[maxn];
long long dp[2][maxn];
inline long long mul(long long a, long long b) { return a * b % mod; }
int main() {
  scanf("%d %d %lld", &n, &m, &mod);
  fac[0] = 1;
  for (int i = 1; i <= m; ++i) fac[i] = fac[i - 1] * i % mod;
  memset(num, 0, sizeof(num));
  num[0][0] = 1;
  for (int i = 1; i <= 5000; ++i)
    for (int j = 1; j <= 5000; ++j)
      num[i][j] = (num[i - 1][j - 1] + num[i - 1][j] * (j - 1) % mod) % mod;
  A[0] = 1;
  for (int i = 1; i <= min(5000, m); ++i) A[i] = (A[i - 1] * (m - i + 1) % mod);
  for (int i = 1; i <= n; ++i) scanf("%d", &len[i]);
  dp[0][0] = 1;
  long long sum = 1;
  int p = 0;
  for (int i = 1; i <= n; ++i) {
    long long tsum = 0;
    memset(dp[p ^ 1], 0, sizeof(dp[p ^ 1]));
    for (int j = 1; j <= len[i]; ++j) {
      dp[p ^ 1][j] = (mul(mul(A[j], num[len[i]][j]), sum) -
                      mul(mul(dp[p][j], num[len[i]][j]), fac[j]) + mod) %
                     mod;
      tsum = (tsum + dp[p ^ 1][j]) % mod;
    }
    sum = tsum;
    p ^= 1;
  }
  printf("%lld\n", sum);
  return 0;
}
