#include <bits/stdc++.h>
int n, m, p, t, s, u, a[1000005], h[1000005], v[1000005], g[5002][5002],
    f[2][5002];
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] > t) t = a[i];
  }
  h[0] = v[m] = g[0][0] = s = 1;
  for (int i = 1; i <= m; i++) h[i] = 1ll * h[i - 1] * i % p;
  for (int i = m; i; i--) v[i - 1] = 1ll * v[i] * i % p;
  for (int i = 1; i <= t; i++)
    for (int j = 1; j <= i && j <= m; j++)
      g[i][j] = (g[i - 1][j - 1] + 1ll * g[i - 1][j] * (j - 1) % p) % p;
  for (int i = 1, b = 0; i <= n; i++, b ^= 1) {
    for (int j = 1; j <= t; j++) f[b][j] = 0;
    for (int j = 1; j <= a[i] && j <= m; j++)
      f[b][j] = (1ll * (1ll * v[m - j] * s % p - 1ll * f[b ^ 1][j] * h[j] % p) *
                     g[a[i]][j] % p +
                 p) %
                p,
      (u += f[b][j]) %= p;
    s = u, u = 0;
  }
  printf("%d", s);
}
