#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int l[1001000];
long long f[2][5010];
long long C[5010];
long long P[5010];
long long jc[5010];
long long pat[5010];
long long dp[5010][5010];
long long quick(long long a, long long x, long long mo) {
  if (!x) return 1;
  long long tmp = quick(a, x / 2, mo);
  tmp *= tmp;
  tmp %= mo;
  if (x & 1) tmp *= a;
  return tmp % mo;
}
int gcd(int x, int y) {
  if (!y) return x;
  return gcd(y, x % y);
}
void prepare(int n, int m, long long mo) {
  int a[m];
  int b[m];
  for (int i = 0; i < (int)(min(n, m)); ++i) a[i] = n - i;
  for (int i = 0; i < (int)(min(n, m)); ++i) b[i] = i + 1;
  memset(C, 0, sizeof(C));
  C[0] = 1;
  for (int i = 0; i < (int)(min(m, n)); ++i) {
    for (int j = 0; j < (int)(i + 1); ++j) {
      int tmp = gcd(a[j], b[i]);
      a[j] /= tmp;
      b[i] /= tmp;
    }
    C[i + 1] = 1;
    for (int j = 0; j < (int)(i + 1); ++j)
      C[i + 1] = (C[i + 1] * (long long)a[j]) % mo;
  }
  memset(P, 0, sizeof(P));
  P[0] = 1;
  for (int i = (int)(1); i <= (int)(min(n, m)); ++i)
    P[i] = (P[i - 1] * (long long)(n - i + 1)) % mo;
  memset(jc, 0, sizeof(jc));
  jc[0] = 1;
  for (int i = (int)(1); i <= (int)(m); ++i)
    jc[i] = (jc[i - 1] * (long long)i) % mo;
  for (int i = (int)(1); i <= (int)(m); ++i)
    pat[i] = (n * quick(n - 1, i - 1, mo)) % mo;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = (int)(1); i <= (int)(m); ++i)
    for (int j = (int)(1); j <= (int)(min(i, n)); ++j)
      dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j] * (long long)(j - 1)) % mo;
  for (int i = (int)(1); i <= (int)(m); ++i)
    for (int j = (int)(1); j <= (int)(min(i, n)); ++j)
      dp[i][j] = (dp[i][j] * jc[j]) % mo;
}
int main() {
  int n, m;
  scanf("%d%d", &(n), &(m));
  long long p;
  scanf("%I64d", &(p));
  memset(l, 0, sizeof(l));
  int mm = 0;
  for (int i = 0; i < (int)(n); ++i) {
    scanf("%d", &(l[i + 1]));
    mm = max(l[i + 1], mm);
  }
  prepare(m, mm, p);
  memset(f, 0, sizeof(f));
  f[0][0] = 1;
  int now = 0;
  int pre = 1;
  for (int i = (int)(1); i <= (int)(n); ++i) {
    pre = now;
    now ^= 1;
    f[now][0] = 0;
    for (int j = (int)(1); j <= (int)(l[i]); ++j) {
      f[now][j] = (f[pre][0] * dp[l[i]][j]) % p;
      if (j <= l[i - 1])
        f[now][j] = (f[now][j] - (f[pre][j] * dp[l[i]][j] % p) + p) % p;
      f[now][0] = (f[now][0] + f[now][j] * C[j]) % p;
    }
  }
  cout << f[now][0];
  return 0;
}
