#include <bits/stdc++.h>
using namespace std;
long long P[5001];
long long Q[5001];
int a[5001][5001];
int dp[2][5001], l[1000001];
int n, m, mod, S;
int max_l = 0;
int main() {
  cin >> n >> m >> mod;
  S = 1;
  a[0][0] = 1LL;
  P[0] = 1LL;
  Q[0] = 1ll;
  for (int i = 1; i <= 5000; i++) {
    for (int j = 1; j <= i; j++) {
      a[i][j] = (a[i - 1][j - 1] + a[i - 1][j] * (j - 1LL)) % mod;
    }
    P[i] = (P[i - 1] * (m - i + 1)) % mod;
    Q[i] = Q[i - 1] * (i) % mod;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", l + i);
    for (int j = 1; j <= min(m, l[i]); j++) {
      dp[i & 1][j] =
          (((S * P[j] - dp[~i & 1][j] * Q[j]) % mod + mod) * a[l[i]][j]) % mod;
    }
    S = accumulate(dp[i & 1], dp[i & 1] + l[i] + 1, 0LL) % mod;
    fill_n(dp[~i & 1], l[i - 1] + 1, 0LL);
  }
  cout << S << endl;
}
