#include <bits/stdc++.h>
using namespace std;
int f[5050][5050];
int fac[5050];
int fax[5050];
int n, m, mod;
vector<int> d[1000020];
int l[1000020];
void init() {
  fac[0] = 1;
  for (int i = 1; i < 5050; ++i) fac[i] = 1LL * fac[i - 1] * i % mod;
  fax[0] = 1;
  for (int i = 1; i < 5050 && i <= m; ++i)
    fax[i] = 1LL * fax[i - 1] * (m - i + 1) % mod;
  f[0][0] = 1;
  for (int i = 1; i < 5050; ++i)
    for (int j = 1; j <= i; ++j)
      f[i][j] = (1LL * f[i - 1][j] * (j - 1) % mod + f[i - 1][j - 1]) % mod;
}
void solve() {
  int sum = 1;
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= l[i]; ++j) {
      d[i][j] = 1LL * sum * fax[j] % mod * f[l[i]][j] % mod;
      if (i > 1 && l[i - 1] >= j)
        d[i][j] = (d[i][j] -
                   1LL * d[i - 1][j] * f[l[i]][j] % mod * fac[j] % mod + mod) %
                  mod;
      ret = (ret + d[i][j]) % mod;
    }
    sum = ret;
    ret = 0;
  }
  printf("%d\n", sum);
}
int main() {
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &l[i]);
    d[i].resize(l[i] + 1);
  }
  init();
  solve();
  return 0;
}
