#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int L = 5010;
int mod;
long long f[L][L];
long long A[L], fact[L];
long long dp[2][L];
int n, m;
int a[N];
int main() {
  cin >> n >> m >> mod;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  A[0] = fact[0] = 1;
  for (int i = 1; i < L; i++) {
    A[i] = A[i - 1] * (m - i + 1) % mod;
    fact[i] = fact[i - 1] * i % mod;
  }
  for (int i = 1; i < L; i++) {
    f[i][1] = (i == 1 ? 1 : 0);
    for (int j = 2; j <= i; j++) {
      f[i][j] = f[i - 1][j - 1] + f[i - 1][j] * (j - 1);
      f[i][j] %= mod;
    }
  }
  int cur = 0;
  long long sum = 1;
  for (int i = 0; i < n; i++) {
    cur ^= 1;
    for (int j = 1; j <= m && j <= a[i]; j++) {
      dp[cur][j] = f[a[i]][j] * A[j] % mod * sum % mod;
      if (i > 0 && j <= a[i - 1])
        dp[cur][j] -= dp[cur ^ 1][j] * f[a[i]][j] % mod * fact[j] % mod;
      dp[cur][j] %= mod;
    }
    sum = 0;
    for (int j = 1; j <= m && j <= a[i]; j++) sum += dp[cur][j];
    sum = (sum % mod + mod) % mod;
  }
  cout << sum << endl;
  return 0;
}
