#include <bits/stdc++.h>
using namespace std;
const int N = 1000050;
int n, m, li[N], opt;
long long mod, jie[N], dp[5005][5005], ans[2][5005], ret, lp[N];
long long KSM(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    p >>= 1;
  }
  return ret;
}
inline long long mul(long long a, long long b) { return a * b % mod; }
int main() {
  scanf("%d%d%lld", &n, &m, &mod);
  for (int i = 1; i <= n; i++) scanf("%d", &li[i]);
  jie[0] = 1;
  for (long long i = 1; i <= m; i++) jie[i] = (jie[i - 1] * i) % mod;
  lp[0] = 1;
  for (long long i = 1; i <= m; i++) lp[i] = mul(lp[i - 1], (m - i + 1));
  dp[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (long long j = 1; j <= 5000; j++)
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] * (j - 1ll) % mod) % mod;
  for (int i = 1; i <= n; i++) {
    ret = 0;
    for (int j = 1; j <= li[i - 1]; j++) ret = (ret + ans[opt][j]) % mod;
    if (i == 1) ret++;
    opt ^= 1;
    for (long long j = 1; j <= min(li[i], m); j++) {
      ans[opt][j] = ret * lp[j] % mod;
      long long p = ans[opt ^ 1][j];
      if (j > li[i - 1]) p = 0;
      ans[opt][j] -= p * jie[j] % mod;
      ans[opt][j] %= mod;
      ans[opt][j] = ans[opt][j] * dp[li[i]][j] % mod;
    }
  }
  ret = 0;
  for (int i = 1; i <= li[n]; i++) ret = (ret + ans[opt][i]) % mod;
  cout << (ret + mod) % mod << endl;
  return 0;
}
