#include <bits/stdc++.h>
using namespace std;
long long n, m, p;
long long A[5001];
long long a[5001];
long long l[1000005];
long long dp[2][5001];
long long s[5001][5001];
void work(long long *prev, long long *nxt) {
  long long total = 0, prev_total = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= min(l[i], m); j++) {
      nxt[j] = (s[l[i]][j] * A[j] % p) * prev_total % p;
      if (j <= l[i - 1])
        nxt[j] = (nxt[j] - ((prev[j] * a[j] % p) * s[l[i]][j]) % p + p) % p;
      total = (total + nxt[j]) % p;
    }
    swap(nxt, prev);
    memset(nxt, 0, sizeof(long long) * 5000);
    prev_total = total;
    total = 0;
  }
  printf("%I64d\n", prev_total);
}
int main() {
  scanf("%I64d %I64d %I64d", &n, &m, &p);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &l[i]);
  }
  a[0] = 1;
  A[0] = 1;
  for (int i = 1; i <= 5000; i++) {
    A[i] = A[i - 1] * (m - i + 1) % p;
    a[i] = a[i - 1] * i % p;
  }
  s[0][0] = 1;
  for (int i = 1; i <= 5000; i++)
    for (int j = 1; j <= i; j++) {
      s[i][j] = (s[i - 1][j - 1] + s[i - 1][j] * (j - 1) % p) % p;
    }
  work(dp[0], dp[1]);
}
