#include <bits/stdc++.h>
using namespace std;
int fc[5000 + 1], P[5000 + 1], d[5000 + 1], a[5000 + 1][5000 + 1];
int main() {
  int n, m, p, i, j, l, pre = 0, sum = 1;
  scanf("%d%d%d", &n, &m, &p);
  a[0][0] = 1;
  for (i = 1; i <= 5000; i++)
    for (j = 1; j <= i && j <= m; j++)
      a[i][j] = (a[i - 1][j - 1] + a[i - 1][j] * (long long)(j - 1)) % p;
  fc[0] = 1, P[0] = 1;
  for (i = 1; i <= 5000 && i <= m; i++)
    fc[i] = fc[i - 1] * (long long)(i) % p,
    P[i] = P[i - 1] * (long long)(m - i + 1) % p;
  for (i = 0; i < n; i++) {
    scanf("%d", &l);
    int temp = 0;
    for (j = 1; j <= l && j <= m; j++) {
      d[j] = ((long long)(sum)*P[j] % p - (long long)(d[j]) * fc[j] % p + p) %
             p * a[l][j] % p;
      temp = (temp + d[j]) % p;
    }
    for (j = l + 1; j <= pre && j <= m; j++) d[j] = 0;
    pre = l, sum = temp;
  }
  printf("%d\n", sum);
  return 0;
}
