#include <bits/stdc++.h>
const int C = 5001, D = 7, E = 1000001;
int cn[C], primes[C], dv[C][D], value[C], ij[C], l[E], res[C], tmp[C], dp[C][C],
    fac[C], full_res[E];
int main() {
  int n, m, p, i, j, x, partial, jj;
  for (i = 2; i < C; i++) primes[i] = 1;
  for (i = 2; i < C; i++) {
    if (primes[i] == 0) continue;
    for (j = i; j < C; j += i) {
      dv[j][ij[j]] = i;
      if (j != i) primes[j] = 0;
      ij[j]++;
    }
  }
  scanf("%d %d %d", &n, &m, &p);
  for (i = 0; i < n; i++) scanf("%d", &l[i]);
  cn[0] = 1;
  for (i = 1; i <= (((C - 1) < (m)) ? (C - 1) : (m)); i++) {
    cn[i] = 1, partial = i;
    value[i - 1] = m - i + 1;
    for (j = 0; j < i; j++) {
      for (jj = 0; jj < ij[partial];) {
        if (value[j] % dv[partial][jj] == 0)
          value[j] /= dv[partial][jj], partial /= dv[partial][jj];
        else
          jj++;
      }
      cn[i] = (1ll * cn[i] * value[j]) % p;
    }
  }
  fac[0] = 1;
  for (i = 1; i < C; i++) fac[i] = (1ll * fac[i - 1] * i) % p;
  dp[0][0] = 1;
  for (i = 1; i < C; i++) {
    for (j = 1; j < C; j++) {
      dp[i][j] = ((1ll * (j - 1) * dp[i - 1][j] + dp[i - 1][j - 1]) % p) % p;
    }
  }
  for (i = 1; i < C; i++) {
    for (j = 1; j < C; j++) {
      dp[i][j] = (1ll * dp[i][j] * fac[j]) % p;
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j <= l[i]; j++) {
      if (i == 0)
        tmp[j] = (1ll * dp[l[0]][j] * cn[j]) % p;
      else
        tmp[j] = (((1ll * full_res[i - 1] * dp[l[i]][j]) % p) * cn[j] -
                  1ll * res[j] * dp[l[i]][j]) %
                 p;
      full_res[i] = (full_res[i] + tmp[j]) % p;
    }
    for (j = 0; j <= l[i]; j++) res[j] = tmp[j];
    for (j = l[i] + 1; i > 0 && j <= l[i - 1]; j++) res[j] = 0;
  }
  if (full_res[n - 1] < 0) full_res[n - 1] += p;
  printf("%d\n", full_res[n - 1]);
  return 0;
}
