#include <bits/stdc++.h>
using namespace std;
inline char gc() { return getchar(); }
inline void pc(char c) {
  putchar(c);
  return;
}
char buffer[25], en;
inline long long read() {
  long long x = 0, f = 1;
  char c = gc();
  while (c < '0' || c > '9') {
    if (c == '-') f = -f;
    c = gc();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = gc();
  return x * f;
}
inline void write(long long x, char end = '\n') {
  if (x == 0) {
    pc('0');
    pc(end);
    return;
  }
  en = 0;
  if (x < 0) pc('-'), x = -x;
  while (x) {
    buffer[++en] = x % 10 + '0';
    x /= 10;
  }
  for (long long i = en; i; i--) pc(buffer[i]);
  pc(end);
  return;
}
long long mod;
long long tim[5005], A[5005], dp1[5005][5005], dp2[2][5005];
inline void pre(long long n, long long m) {
  tim[0] = A[0] = dp1[0][0] = 1;
  for (long long i = 1; i <= n; i++) tim[i] = tim[i - 1] * i % mod;
  for (long long i = 1; i <= n; i++) A[i] = A[i - 1] * (m - i + 1) % mod;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= min(m, i); j++)
      dp1[i][j] =
          (dp1[i - 1][j] * (j - 1) % mod + dp1[i - 1][j - 1] % mod) % mod;
  return;
}
long long l[1000005];
signed main() {
  long long n = read(), m = read();
  mod = read();
  long long N = 0;
  for (long long i = 1; i <= n; i++) l[i] = read(), N = max(N, l[i]);
  pre(N, m);
  long long now = 0;
  long long sum = 1;
  for (long long i = 1; i <= n; i++) {
    now ^= 1;
    memset(dp2[now], 0, sizeof(dp2[now]));
    for (long long j = 1; j <= l[i]; j++)
      dp2[now][j] = ((A[j] * dp1[l[i]][j] % mod * sum % mod -
                      tim[j] * dp1[l[i]][j] % mod * dp2[now ^ 1][j] % mod) %
                         mod +
                     mod) %
                    mod;
    sum = 0;
    for (long long j = 1; j <= l[i]; j++) sum = (sum + dp2[now][j]) % mod;
  }
  write(sum);
}
