#include <bits/stdc++.h>
using namespace std;
int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, p;
long long C[1000005], l[1000005], g[5005], fac[5005], pr[5005];
int f[5005][5005];
void pre() {
  C[0] = 1;
  for (int i = 1; i <= m; i++) C[i] = C[i - 1] * (m - i + 1) % p;
  f[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (int j = 1; j <= min(i, m); j++) {
      f[i][j] = (long long)f[i - 1][j] * (j - 1) % p + f[i - 1][j - 1];
      f[i][j] %= p;
    }
  fac[1] = 1;
  for (int i = 2; i <= 5000; i++) fac[i] = fac[i - 1] * i % p;
}
void dp() {
  long long sum = 1, tmp;
  for (int i = 1; i <= n; i++) {
    tmp = 0;
    for (int j = 1; j <= l[i]; j++)
      g[j] = (sum * C[j] % p * f[l[i]][j] % p -
              f[l[i]][j] * pr[j] % p * fac[j] % p + p) %
             p;
    for (int j = 1; j <= l[i]; j++) tmp = (tmp + g[j]) % p;
    sum = tmp;
    for (int j = 1; j <= l[i - 1]; j++) pr[j] = 0;
    for (int j = 1; j <= l[i]; j++) pr[j] = g[j];
  }
  cout << sum << endl;
}
int main() {
  n = read();
  m = read();
  p = read();
  pre();
  for (int i = 1; i <= n; i++) l[i] = read();
  dp();
  return 0;
}
