#include <bits/stdc++.h>
using namespace std;
int NN = 5000;
int N, M, P;
int l[1000006];
int fac[1000006], f[1000006];
int dp[5005][5005];
int g[5005], temp[5005];
int main() {
  scanf("%d%d%d", &N, &M, &P);
  for (int i = 1; i <= N; i++) {
    scanf("%d", &l[i]);
  }
  f[0] = fac[0] = 1;
  for (int i = 1; i <= M; i++) {
    fac[i] = (long long)fac[i - 1] * i % P;
    f[i] = (long long)f[i - 1] * (M - i + 1) % P;
  }
  dp[0][0] = 1;
  for (int i = 1; i <= NN; i++) {
    for (int j = 1; j <= min(i, M); j++) {
      dp[i][j] = (dp[i - 1][j - 1] + (long long)dp[i - 1][j] * (j - 1) % P) % P;
    }
  }
  long long sum = 1;
  for (int i = 1; i <= N; i++) {
    memset(g, 0, sizeof(g));
    for (int j = 1; j <= l[i]; j++) {
      g[j] = ((long long)f[j] * dp[l[i]][j] % P * sum % P -
              (long long)temp[j] * dp[l[i]][j] % P * fac[j] % P + P) %
             P;
    }
    sum = 0;
    for (int j = 1; j <= l[i]; j++) {
      sum = (sum + g[j]) % P;
    }
    memcpy(temp, g, sizeof(g));
  }
  cout << sum << endl;
  return 0;
}
