#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T a) {
  return ((a < 0) ? -a : a);
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
const int INF = (int)1E9 + 7;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
int M;
const int N = 1000100;
const int K = 5010;
int C[K][K];
int Am[K];
int fact[K];
int n, m;
int ln[N];
int z[K][K];
vector<int> d[2];
int main() {
  cin >> n >> m >> M;
  C[0][0] = 1;
  Am[0] = 1;
  fact[0] = 1;
  for (int i = 1; i < K; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % M;
    if (i > m)
      Am[i] = 0;
    else
      Am[i] = (Am[i - 1] * 1ll * (m - i + 1)) % M;
    fact[i] = (fact[i - 1] * 1ll * i) % M;
  }
  for (int i = 0; i < int(n); ++i) scanf("%d", &ln[i]);
  z[1][1] = 1;
  for (int i = 2; i < K; ++i)
    for (int j = 2; j <= i; ++j)
      z[i][j] = (z[i - 1][j - 1] + (z[i - 1][j] * 1ll * (j - 1))) % M;
  int sumD = 1;
  for (int i = 0; i < n; ++i) {
    d[i & 1].clear();
    d[i & 1].resize(ln[i] + 1);
    int nextSum = 0;
    for (int j = 1; j <= ln[i]; ++j) {
      d[i & 1][j] = (((Am[j] * 1ll * z[ln[i]][j]) % M) * 1ll * sumD) % M;
      if (i > 0 && j <= ln[i - 1]) {
        int dec =
            (((z[ln[i]][j] * 1ll * d[(i - 1) & 1][j]) % M) * 1ll * fact[j]) % M;
        d[i & 1][j] = (M + d[i & 1][j] - dec) % M;
      }
      nextSum += d[i & 1][j];
      nextSum %= M;
    }
    sumD = nextSum;
  }
  cout << sumD << endl;
  return 0;
}
