#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long mod) {
  if (y < 0) return power(power(x, mod - 2, mod), -y, mod);
  long long res = 1;
  for (; y; y >>= 1, x = x * x % mod)
    if (y & 1) res = res * x % mod;
  return res;
}
const int nn = 5002, mm = 1000100;
int p[nn][nn];
int n, m, mod, lm;
int l[mm], f[2][nn], B[nn];
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
map<int, int> ma;
void addf(int x, int d) {
  int k = 2;
  while (x > 1) {
    if ((long long)k * k > x) k = x;
    while (x % k == 0) {
      ma[k] += d;
      x /= k;
    }
    k++;
  }
}
void func() {
  B[0] = 1;
  for (int i = 1; i <= min(m, lm); ++i) {
    addf(m - i + 1, 1);
    addf(i, -1);
    B[i] = 1;
    for (map<int, int>::iterator it = ma.begin(); it != ma.end(); ++it)
      B[i] = (long long)B[i] * power(it->first, it->second, mod) % mod;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &mod);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &l[i]);
    lm = max(lm, l[i]);
  }
  p[0][0] = 1;
  for (int i = 1; i <= lm; ++i) {
    for (int j = 1; j <= lm; ++j) {
      p[i][j] =
          ((long long)p[i - 1][j] * (j - 1) + (long long)p[i - 1][j - 1] * j) %
          mod;
    }
  }
  func();
  int now = 0, sum = 1;
  f[now][0] = 1;
  for (int i = 1; i <= n; ++i) {
    now ^= 1;
    int s = 0;
    for (int j = 1; j <= l[i]; ++j) {
      f[now][j] = (long long)sum * B[j] % mod * p[l[i]][j] % mod;
      add(f[now][j], mod - (long long)p[l[i]][j] *
                               (j > l[i - 1] ? 0 : f[now ^ 1][j]) % mod);
      add(s, f[now][j]);
    }
    sum = s;
  }
  cout << sum << endl;
  return 0;
}
