#include <bits/stdc++.h>
using namespace std;
long long dp[2][5005], w[5005][5005], c[5005];
int prime[10005], cnt, n, m, p, l[1000005];
int num[10005];
void find_prime() {
  cnt = 0;
  for (int i = 2; i * i < 1000000; i++) {
    bool flag = true;
    for (int j = 0; j < cnt; j++)
      if (i % prime[j] == 0) {
        flag = false;
        break;
      }
    if (flag) prime[cnt++] = i;
  }
}
void insert(int k, int j) {
  for (int i = 0; i < cnt; i++) {
    while (k % prime[i] == 0) {
      num[i] += j;
      k = k / prime[i];
    }
  }
  if (k != 1) {
    prime[cnt++] = k;
    num[cnt - 1] = 1;
  }
}
long long k_sqr(int k, int t) {
  long long ret = 1, now = k;
  while (t > 0) {
    if (t % 2 == 1) ret = (ret * now) % p;
    now = (now * now) % p;
    t = t / 2;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 0; i < n; i++) scanf("%d", &l[i]);
  find_prime();
  memset(w, 0, sizeof(w));
  for (int i = 0; i <= 5000; i++) w[0][i] = 1;
  for (int i = 1; i <= 5000; i++) {
    for (int j = 1; j <= i; j++)
      w[i][j] = ((w[i - 1][j] * (j - 1)) % p + (w[i - 1][j - 1] * j) % p) % p;
  }
  int k = min(5000, m);
  for (int i = 1, j = m; i <= k; i++, j--) {
    insert(j, 1);
    insert(i, -1);
    c[i] = 1;
    for (int j = 0; j < cnt; j++)
      if (num[j] != 0) c[i] = (c[i] * k_sqr(prime[j], num[j])) % p;
  }
  long long sum = 1, new_sum = 0;
  for (int i = 0; i < n; i++) {
    int g = i % 2, h = (i + 1) % 2;
    for (int j = 1; j <= min(l[i], m); j++) {
      dp[h][j] = (c[j] * w[l[i]][j]) % p * (sum - dp[g][j]) % p +
                 (c[j] - 1) * w[l[i]][j] % p * dp[g][j] % p;
      dp[h][j] %= p;
      new_sum = (new_sum + dp[h][j]) % p;
    }
    sum = new_sum;
    new_sum = 0;
    for (int j = 1; j <= min(l[i - 1], m); j++) dp[g][j] = 0;
  }
  sum = (sum + p) % p;
  printf("%lld\n", sum);
  return 0;
}
