#include <bits/stdc++.h>
using namespace std;
int N, M, Primes[1000], Tail;
long long P, Base[5000 + 1][5000 + 1];
long long Choose[5000 + 1];
long long DP[2][5000 + 1];
void add(long long &a, long long b) { a = (a + b) % P; }
void map_op(map<int, int> &count, int num, int pl) {
  if (count.find(num) == count.end())
    count[num] = pl;
  else
    count[num] += pl;
}
void fragment(map<int, int> &count, int pl, int num) {
  for (int i = 0; i < Tail && Primes[i] * Primes[i] <= num; i++) {
    int cnt = 0;
    while (num % Primes[i] == 0) {
      cnt++;
      num /= Primes[i];
    }
    if (cnt != 0) map_op(count, Primes[i], pl * cnt);
  }
  if (num != 1) {
    map_op(count, num, pl);
  }
}
void pre_process() {
  int i, j;
  memset(Base, 0, sizeof(Base));
  Base[1][1] = 1;
  for (i = 1; i < 5000; i++) {
    for (j = 1; j <= i; j++)
      if (Base[i][j] != 0) {
        add(Base[i + 1][j], (j - 1) * Base[i][j]);
        add(Base[i + 1][j + 1], (j + 1) * Base[i][j]);
      }
  }
  Choose[0] = 1;
  map<int, int> count;
  Primes[0] = 2;
  Tail = 1;
  for (i = 3; i <= 1000; i++) {
    for (j = 0; j < Tail; j++)
      if (i % Primes[j] == 0) break;
    if (j == Tail) {
      Primes[Tail++] = i;
    }
  }
  for (i = 1; i <= min(5000, M); i++) {
    fragment(count, 1, M - i + 1);
    fragment(count, -1, i);
    Choose[i] = 1;
    for (map<int, int>::iterator it = count.begin(); it != count.end(); it++) {
      for (j = 0; j < (int)(it->second); j++)
        Choose[i] = (Choose[i] * it->first) % P;
    }
  }
}
int main() {
  int tmp;
  scanf("%d%d%d", &N, &M, &tmp);
  P = tmp;
  pre_process();
  int row, color, T = 0, UT, len = -1, bef;
  long long next = 1;
  for (row = 0; row < (int)(N); row++) {
    bef = len;
    scanf("%d", &len);
    UT = T;
    T = !T;
    long long all = next;
    next = 0;
    for (color = 1; color <= min(M, len); color++) {
      long long minus = 0;
      if (bef != -1 && color <= bef) {
        minus = DP[UT][color];
      }
      DP[T][color] = ((all - minus + P) * Base[len][color]) % P;
      add(next, Choose[color] * DP[T][color]);
    }
  }
  long long res = 0;
  for (color = 1; color <= min(M, len); color++) {
    add(res, Choose[color] * DP[T][color]);
  }
  cout << res << endl;
  return 0;
}
