#include <bits/stdc++.h>
using namespace std;
int l[1000000];
int one_line[5001][5001] = {0};
int summ[5001][5001] = {0};
int fac[5001];
int main() {
  int n, m, p;
  scanf("%d %d %d", &n, &m, &p);
  for (int i = 0; i < n; i++) scanf("%d", &l[i]);
  fac[0] = 1;
  for (int i = 1; i <= 5000; i++) fac[i] = ((fac[i - 1]) * (long long)i) % p;
  one_line[1][1] = 1;
  for (int i = 2; i <= 5000; i++) {
    for (int j = 1; j <= min(m, 5000); j++) {
      one_line[i][j] =
          (one_line[i - 1][j] * (long long)(j - 1) + one_line[i - 1][j - 1]) %
          p;
    }
  }
  summ[1][1] = m;
  for (int i = 2; i <= 5000; i++) {
    for (int j = 1; j <= min(m, 5000); j++) {
      summ[i][j] = (summ[i - 1][j] * (long long)(j - 1) +
                    summ[i - 1][j - 1] * (long long)(m - j + 1)) %
                   p;
    }
  }
  int prev_progress[5001] = {0};
  int prev_l = 0;
  prev_progress[0] = 1;
  for (int i = 0; i < n; i++) {
    int next_progress[5001];
    for (int j = 0; j <= l[i]; j++) next_progress[j] = 0;
    int tot1 = 0;
    for (int j = 0; j <= prev_l; j++) tot1 = (tot1 + prev_progress[j]) % p;
    int tot2 = 1;
    tot2 = (tot2 * (long long)m) % p;
    for (int j = 1; j < l[i]; j++) tot2 = (tot2 * (long long)(m - 1)) % p;
    for (int j = 1; j <= l[i]; j++) {
      next_progress[j] = (tot1 * (long long)summ[l[i]][j]) % p;
      int prev = 0;
      if (j <= prev_l) prev = prev_progress[j];
      next_progress[j] -=
          (((prev * (long long)one_line[l[i]][j]) % p) * fac[j]) % p;
      if (next_progress[j] < 0) next_progress[j] += p;
    }
    for (int j = 0; j <= l[i]; j++) prev_progress[j] = next_progress[j];
    prev_l = l[i];
  }
  int res = 0;
  for (int i = 0; i <= prev_l; i++) res = (res + prev_progress[i]) % p;
  printf("%d\n", res);
}
