#include <bits/stdc++.h>
template <typename T>
inline void read(T &x) {
  x = 0;
  char c = getchar();
  bool flag = false;
  while (!isdigit(c)) {
    if (c == '-') flag = true;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  if (flag) x = -x;
}
using namespace std;
int n, m, P, l[1001000];
int f[5100][5100];
int jie[1001000], A[1001000];
inline long long quickpow(long long x, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = res * x % P;
    x = x * x % P;
    k >>= 1;
  }
  return res;
}
inline void init() {
  f[1][1] = 1;
  for (register int i = 2; i <= 5000; ++i) {
    for (register int j = 1; j <= i; ++j) {
      f[i][j] = (1ll * f[i - 1][j] * (j - 1) + f[i - 1][j - 1]) % P;
    }
  }
  jie[0] = 1;
  int limi = min(1000000, P - 1);
  for (register int i = 1; i <= limi; ++i) jie[i] = 1ll * jie[i - 1] * i % P;
  A[0] = 1;
  for (register int i = 1; i <= m; ++i) {
    A[i] = 1ll * A[i - 1] * (m - i + 1) % P;
  }
}
inline void Mod(long long &num) {
  if (num >= P) num -= P;
}
long long g[15100], G[15100];
int main() {
  read(n);
  read(m);
  read(P);
  for (register int i = 1; i <= n; ++i) read(l[i]);
  init();
  long long sum = 1;
  for (register int i = 1; i <= n; ++i) {
    for (register int j = 1; j <= l[i] + l[i - 1]; ++j) G[j] = g[j], g[j] = 0;
    for (register int j = 1; j <= l[i]; ++j) {
      g[j] = 1ll * A[j] * sum % P * f[l[i]][j] % P -
             G[j] * f[l[i]][j] % P * jie[j] % P;
      g[j] %= P;
      if (g[j] < 0) g[j] += P;
    }
    sum = 0;
    for (register int j = 1; j <= l[i]; ++j) Mod(sum += g[j]);
  }
  printf("%lld\n", sum);
  return 0;
}
