#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
const int maxa = 5005;
const int maxl = 1e7 + 5;
int mod, n, m;
int fact[maxn], A[maxn];
int l[maxn], sum[maxn];
vector<int> f[maxn];
int way[maxa][maxa];
void add(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
int mul(int a, int b) { return 1ll * a * b % mod; }
signed main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (fopen("A.INP", "r")) {
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  cin >> n >> m >> mod;
  int L = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> l[i];
    f[i].resize(l[i] + 1, 0);
    L += l[i];
  }
  way[0][0] = 1;
  for (int i = 1; i < maxa; ++i) {
    for (int j = 1; j <= i; ++j) {
      add(way[i][j], (way[i - 1][j - 1] + mul(way[i - 1][j], j - 1)) % mod);
    }
  }
  fact[0] = 1;
  for (int i = 1; i <= 5000; ++i) fact[i] = mul(i, fact[i - 1]);
  A[0] = 1;
  for (int i = 1; i <= m; ++i) A[i] = mul(A[i - 1], (m - i + 1));
  sum[0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= l[i]; ++j) {
      f[i][j] = 1ll * sum[i - 1] * A[j] % mod * way[l[i]][j] % mod;
      if (i > 1 && l[i - 1] >= j)
        f[i][j] =
            (f[i][j] - 1ll * f[i - 1][j] * fact[j] % mod * way[l[i]][j] + mod) %
            mod;
      add(sum[i], f[i][j]);
    }
  }
  cout << sum[n] << '\n';
}
