#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
const int M = 5010;
int g[M][M], f[2][M];
int A[M], jc[M], ans;
int l[N], n, m, p, la;
int main() {
  scanf("%d%d%d", &n, &m, &p);
  for (int i = 1; i <= n; i++) scanf("%d", &l[i]);
  g[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (int j = 1; j <= i; j++)
      g[i][j] = ((long long)g[i - 1][j - 1] +
                 (long long)g[i - 1][j] * (long long)(j - 1)) %
                p;
  A[0] = 1;
  jc[1] = 1;
  for (int i = 1; i <= min(m, 5000); i++)
    A[i] = ((long long)A[i - 1] * (long long)(m - i + 1)) % p;
  for (int i = 2; i <= 5000; i++)
    jc[i] = ((long long)jc[i - 1] * (long long)i) % p;
  la = 1;
  for (int i = 1; i <= n; i++) {
    int sum = 0;
    for (int j = 1; j <= min(m, l[i]); j++) {
      f[i & 1][j] =
          ((long long)la * (long long)A[j] % p * (long long)g[l[i]][j]) % p;
      if (l[i - 1] >= j)
        f[i & 1][j] = (f[i & 1][j] -
                       (long long)f[(i - 1) & 1][j] * (long long)g[l[i]][j] %
                           p * (long long)jc[j] % p +
                       p) %
                      p;
      sum = (sum + f[i & 1][j]) % p;
    }
    la = sum;
  }
  printf("%d\n", la);
  return 0;
}
