#include <bits/stdc++.h>
using namespace std;
int n, m, p, a[1000010];
int d[5010][5010];
long long dp[2][5010], f[5010], A[5010];
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  d[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (int j = 1; j <= i; j++) {
      d[i][j] = (1ll * d[i - 1][j - 1] + 1ll * d[i - 1][j] * (j - 1) % p) % p;
    }
  A[0] = 1;
  for (int i = 1; i <= 5000 && i <= m; i++) A[i] = A[i - 1] * (m - i + 1) % p;
  f[0] = 1;
  for (int i = 1; i <= 5000; i++) f[i] = f[i - 1] * i % p;
  long long sum1 = 1, sum2 = 0;
  for (int i = 1; i <= n; i++) {
    sum2 = 0;
    for (int j = 1; j <= a[i] && j <= m; j++) {
      dp[i & 1][j] = sum1 * d[a[i]][j] % p * A[j] % p;
      dp[i & 1][j] =
          dp[i & 1][j] + p - dp[(i - 1) & 1][j] * f[j] % p * d[a[i]][j] % p;
      dp[i & 1][j] = (dp[i & 1][j] % p + p) % p;
      sum2 += dp[i & 1][j];
    }
    sum1 = sum2 % p;
    memset(dp[(i + 1) & 1], 0, sizeof(dp[(i + 1) & 1]));
  }
  cout << sum1 << endl;
  return 0;
}
