#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
const int M = 1000005;
int n, m;
long long p;
long long l[M];
long long fac[M], jie[M];
long long dp[N][N];
long long f[N], g[N];
int main() {
  cin >> n >> m >> p;
  for (int i = 1; i <= n; i++) scanf("%lld", &l[i]);
  jie[0] = fac[0] = 1;
  for (int i = 1; i <= m; i++) {
    fac[i] = fac[i - 1] * i % p;
    jie[i] = jie[i - 1] * (m - i + 1) % p;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (int j = 1; j <= min(i, m); j++)
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] * (j - 1) % p) % p;
  long long sum = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= l[i]; j++)
      f[j] = (jie[j] * dp[l[i]][j] % p * sum % p -
              g[j] * dp[l[i]][j] % p * fac[j] % p + p) %
             p;
    sum = 0;
    for (int j = 1; j <= l[i]; j++) sum = (sum + f[j]) % p;
    for (int j = 1; j <= l[i - 1]; j++) g[j] = 0;
    for (int j = 1; j <= l[i]; j++) g[j] = f[j];
  }
  cout << sum << endl;
  return 0;
}
