#include <bits/stdc++.h>
using namespace std;
int N, M, P;
int lc[5005][5005];
void add(int &a, int b) { a = (a + b) % P; }
void calc_lc() {
  lc[1][1] = 1;
  for (int i = 1; i < 5000; i++) {
    for (int j = 1; j <= i; j++) {
      add(lc[i + 1][j], lc[i][j] * (long long)(j - 1) % P);
      add(lc[i + 1][j + 1], lc[i][j]);
    }
  }
  for (int i = 1; i <= 5000; i++) {
    int mul = 1;
    for (int j = 1; j <= i; j++) {
      mul = mul * (long long)j % P;
      lc[i][j] = lc[i][j] * (long long)mul % P;
    }
  }
}
vector<pair<int, int> > expr[1100000];
int np[1100000];
void decompose(int n) {
  for (int i = 2; i * i <= n; i++) {
    if (np[i] != 0) continue;
    for (int j = i * i; j <= n; j += i) np[j] = i;
  }
  for (int i = 1; i <= n; i++) {
    if (np[i] == 0)
      expr[i].push_back(pair<int, int>(i, 1));
    else {
      int ti = i, j = 0;
      while (ti % np[i] == 0) {
        ti /= np[i];
        j++;
      }
      expr[i] = expr[ti];
      expr[i].push_back(pair<int, int>(np[i], j));
    }
  }
}
int power(long long a, int b, int mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
int num[5001], C[5500];
void calc_C(int M) {
  memset(num, 0, sizeof(num));
  C[0] = 1;
  int com = 1;
  for (int i = 1; i <= 5000 && i <= M; i++) {
    int j = M + 1 - i;
    for (int k = 0; k < (int)expr[j].size(); k++) {
      if (expr[j][k].first > 5000) {
        com =
            com * (long long)power(expr[j][k].first, expr[j][k].second, P) % P;
      } else {
        num[expr[j][k].first] += expr[j][k].second;
      }
    }
    for (int k = 0; k < (int)expr[i].size(); k++)
      num[expr[i][k].first] -= expr[i][k].second;
    int res = com;
    for (int k = 2; k <= 5000; k++) {
      if (num[k]) res = res * (long long)power(k, num[k], P) % P;
    }
    C[i] = res;
  }
}
int l[1100000];
int dp[2][5500];
int main() {
  while (scanf("%d %d %d", &N, &M, &P) != EOF) {
    calc_lc();
    decompose(M);
    calc_C(M);
    for (int i = 1; i <= N; i++) scanf("%d", l + i);
    int now = 0;
    for (int i = 1; i <= l[1]; i++)
      dp[now][i] = C[i] * (long long)lc[l[1]][i] % P;
    for (int i = 2; i <= N; i++) {
      int sum = 0;
      for (int j = 1; j <= l[i - 1]; j++) add(sum, dp[now][j]);
      for (int j = 1; j <= l[i]; j++) {
        if (j > l[i - 1]) dp[now][j] = 0;
        int ts = (sum - dp[now][j]) % P;
        dp[!now][j] = C[j] * (long long)lc[l[i]][j] % P * ts % P;
        add(dp[!now][j],
            (C[j] - 1) * (long long)lc[l[i]][j] % P * dp[now][j] % P);
      }
      now = !now;
    }
    int sum = 0;
    for (int i = 1; i <= l[N]; i++) add(sum, dp[now][i]);
    sum = (sum + P) % P;
    printf("%d\n", sum);
  }
}
