#include <bits/stdc++.h>
using namespace std;
const int MAXL = 5000 + 10;
const int MAXN = 1000000 + 10;
int n, m, mod;
int l[MAXN], dp[MAXL], fact[MAXL];
int c[MAXL][MAXL];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> mod;
  for (int i = 1; i <= n; i++) cin >> l[i];
  c[1][1] = 1;
  for (int i = 2; i < MAXL; i++)
    for (int j = 2; j <= min(m, i); j++)
      c[i][j] = (c[i - 1][j - 1] + (long long)c[i - 1][j] * (j - 1)) % mod;
  for (int j = 1; j <= l[1]; j++) dp[j] = c[l[1]][j];
  fact[0] = 1;
  for (int i = 1; i < MAXL; i++) fact[i] = (long long)fact[i - 1] * i % mod;
  int ans = 0;
  for (int i = 2; i <= n + 1; i++) {
    int tot = 0, cur = m;
    for (int j = 1; j <= l[i - 1]; j++) {
      tot = (tot + (long long)cur * dp[j]) % mod;
      cur = (long long)cur * (m - j) % mod;
    }
    ans = tot;
    for (int j = 1; j <= l[i]; j++)
      dp[j] = (j <= l[i - 1]) ? ((long long)c[l[i]][j] *
                                 (tot - (long long)dp[j] * fact[j] % mod) % mod)
                              : ((long long)c[l[i]][j] * tot % mod);
  }
  if (ans < 0) ans += mod;
  cout << ans << endl;
  return 0;
}
