#include <bits/stdc++.h>
using namespace std;
int n, m, mo, l[1000001], yu = 0, la = 0, C[5005], a[5005], f[2][5005];
int dp[5005][5005], g[2][5005];
int gcd(int o, int p) { return (!p) ? o : gcd(p, o % p); }
int mi(int o, int p) {
  if (!p) return 1;
  if (!o) return 0;
  int u = 1;
  while (p > 0) {
    if (p & 1) u = 1ll * u * o % mo;
    o = 1ll * o * o % mo;
    p >>= 1;
  }
  return u;
}
int s(int o, int p) {
  if (!o) return 0;
  if (o < p) return 0;
  if ((p == 1) && (o > 1)) return 0;
  int yu = 1ll * p * mi(p - 1, o - 1) % mo;
  return yu;
}
int main() {
  scanf("%d%d%d", &n, &m, &mo);
  C[0] = 1;
  for (int i = 1; i <= min(m, 5000); i++) a[i] = m - i + 1;
  for (int i = 1; i <= min(m, 5000); i++) {
    int yu = i;
    for (int j = 1; j <= i; j++) {
      int d = gcd(yu, a[j]);
      a[j] /= d;
      yu /= d;
      if (yu == 1) break;
    }
    C[i] = 1;
    for (int j = 1; j <= i; j++) C[i] = 1ll * C[i] * a[j] % mo;
  }
  int mx = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &l[i]);
    mx = max(mx, l[i]);
  }
  dp[1][1] = 1;
  for (int i = 2; i <= mx; i++) {
    int yu = 0;
    for (int j = 1; j <= i; j++)
      dp[i][j] = (1ll * dp[i - 1][j] * (j - 1) % mo +
                  1ll * dp[i - 1][j - 1] * j % mo) %
                 mo;
  }
  la = 1;
  for (int i = 1; i <= n; i++) {
    memset(g[i & 1], 0, sizeof(g[i & 1]));
    for (int j = 1; j <= min(m, l[i]); j++) {
      g[i & 1][j] =
          1ll * ((la - g[(i & 1) ^ 1][j] + mo) % mo) * dp[l[i]][j] % mo;
      f[i & 1][j] = 1ll * ((la - g[(i & 1) ^ 1][j] + mo) % mo) * dp[l[i]][j] %
                    mo * C[j] % mo;
      yu = (yu + f[i & 1][j]) % mo;
    }
    la = yu;
    yu = 0;
  }
  cout << la << endl;
  return 0;
}
