#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000007;
const int maxv = 5007;
int n, m, p, a[maxn];
long long P[maxv], dp[2][maxv], cnt[maxv][maxv], frac[maxv];
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  P[0] = 1;
  frac[0] = 1;
  for (int i = 1; i <= 5000; ++i) {
    P[i] = P[i - 1] * (m - i + 1) % p;
    frac[i] = frac[i - 1] * i % p;
  }
  memset(dp, 0, sizeof(dp));
  cnt[0][0] = 1;
  for (int i = 1; i <= 5000; ++i)
    for (int j = 1; j <= 5000; ++j)
      cnt[i][j] = (cnt[i - 1][j - 1] + cnt[i - 1][j] * (j - 1)) % p;
  int flag = 0;
  a[0] = 0;
  dp[flag][0] = 1;
  for (int i = 1; i <= n; ++i) {
    long long sum = 0;
    flag ^= 1;
    memset(dp[flag], 0, sizeof(dp[flag]));
    for (int j = 0; j <= a[i - 1]; ++j) sum = (sum + dp[flag ^ 1][j]) % p;
    for (int j = 1; j <= min(m, a[i]); ++j) {
      dp[flag][j] = sum * P[j] % p * cnt[a[i]][j] % p;
      if (j <= a[i - 1])
        dp[flag][j] = (dp[flag][j] -
                       dp[flag ^ 1][j] * cnt[a[i]][j] % p * frac[j] % p + p) %
                      p;
    }
  }
  long long res = 0;
  for (int i = 1; i <= a[n]; ++i) res = (res + dp[flag][i]) % p;
  cout << res << endl;
}
