#include <bits/stdc++.h>
using namespace std;
int n, m;
bool debug = false;
int k, ans;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long p, a[5005][5005], fac[5005], d[2][5005], nfac[5005];
int l[2];
int main() {
  scanf("%d%d%lld", &n, &m, &p);
  a[0][0] = 1;
  fac[0] = 1;
  nfac[0] = 1;
  for (int i = 1; i <= 5000; i++) {
    for (int j = 1; j <= i; j++) {
      a[i][j] = (a[i - 1][j - 1] + a[i - 1][j] * (j - 1) % p) % p;
    }
    fac[i] = fac[i - 1] * i % p;
    nfac[i] = nfac[i - 1] * (m - i + 1) % p;
  }
  long long S = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &l[i & 1]);
    long long ts = 0;
    for (int j = 1; j <= min(l[i & 1], m); j++) {
      d[i & 1][j] =
          ((S * nfac[j] - d[~i & 1][j] * fac[j]) % p + p) * a[l[i & 1]][j] % p;
      ts = (ts + d[i & 1][j]) % p;
    }
    S = ts;
    for (int j = 0; j < l[~i & 1] + 1; j++) d[~i & 1][j] = 0;
  }
  printf("%lld\n", S);
  return 0;
}
