#include <bits/stdc++.h>
using namespace std;
int n, m, mod;
int l[1000005];
long long sum;
long long f[5005][5005], fac[5005], C[1000005], g[2][5005];
int main() {
  int i, j;
  scanf("%d%d%d", &n, &m, &mod);
  for (i = 1; i <= n; i++) scanf("%d", &l[i]);
  fac[0] = C[0] = f[0][0] = sum = 1LL;
  for (i = 1; i <= 5000; i++) fac[i] = (fac[i - 1] * i) % mod;
  for (i = 1; i <= m; i++) C[i] = C[i - 1] * (m - i + 1) % mod;
  for (i = 1; i <= 5000; i++)
    for (j = 1; j <= min(i, m); j++)
      f[i][j] = (f[i - 1][j - 1] + f[i - 1][j] * (j - 1) % mod) % mod;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= min(l[i], m); j++)
      g[i & 1][j] =
          (C[j] * sum % mod - fac[j] * g[(i + 1) & 1][j] % mod + mod) % mod *
          f[l[i]][j] % mod;
    for (j = 1, sum = 0LL; j <= min(l[i], m); j++)
      sum = (sum + g[i & 1][j]) % mod;
    for (j = 1; j <= min(l[i - 1], m); j++) g[(i + 1) & 1][j] = 0;
  }
  printf("%lld", sum);
  fclose(stdin);
  fclose(stdout);
  return 0;
}
