#include <bits/stdc++.h>
using namespace std;
const int NICO = 5002;
long long n, m, p;
long long alt_way[NICO + 2][NICO + 2];
long long ways[NICO + 2];
long long perm[NICO + 2];
long long fact[NICO + 2];
long long len[1000000 + 2];
void init() {
  alt_way[1][1] = 1;
  for (int i = 1; i < NICO; i++) {
    for (int j = 1; j <= i; j++) {
      (alt_way[i + 1][j + 1] += alt_way[i][j]) %= p;
      (alt_way[i + 1][j] += (alt_way[i][j] * (j - 1) % p)) %= p;
    }
  }
  fact[0] = perm[0] = 1;
  for (int i = 0; i < NICO - 1; i++) {
    fact[i + 1] = fact[i] * (i + 1) % p;
    perm[i + 1] = perm[i] * (m - i) % p;
  }
}
int main() {
  cin >> n >> m >> p;
  init();
  for (int i = 1; i <= n; i++) {
    scanf("%lld", &len[i]);
  }
  for (int i = 1; i <= len[1]; i++) {
    ways[i] = alt_way[len[1]][i];
  }
  for (int i = 2; i <= n; i++) {
    long long tot = 0;
    for (int j = 1; j <= len[i - 1]; j++) {
      (tot += (ways[j] * perm[j] % p)) %= p;
    }
    for (int j = 1; j <= len[i]; j++) {
      ways[j] = (tot - ((j > len[i - 1]) ? 0 : ways[j]) * fact[j] % p) *
                alt_way[len[i]][j] % p;
      ways[j] = (ways[j] % p + p) % p;
    }
  }
  long long answer = 0;
  for (int i = 1; i <= len[n]; i++) {
    answer =
        ((answer + (long long)ways[i] * (long long)perm[i] % p) % p + p) % p;
  }
  printf("%lld\n", answer);
}
