#include <bits/stdc++.h>
using namespace std;
int N, M, P;
int L[1000005], a1[1000005], a2[1000005];
int dp[5005][5005], g1[5005], g2[5005];
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M >> P;
  for (int i = 1; i <= N; i++) cin >> L[i];
  a1[0] = a2[0] = 1;
  for (int i = 1; i <= M; i++)
    a1[i] = ((long long)a1[i - 1] * i) % P,
    a2[i] = ((long long)a2[i - 1] * (M - i + 1)) % P;
  dp[0][0] = 1;
  for (int i = 1; i < 5005; 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(g1, 0, sizeof g1);
    for (int j = 1; j <= L[i]; j++)
      g1[j] = (((long long)a2[j] * dp[L[i]][j]) % P * sum % P -
               ((long long)g2[j] * dp[L[i]][j]) % P * a1[j] % P + P) %
              P;
    sum = 0;
    for (int j = 1; j <= L[i]; j++) sum = (sum + g1[j]) % P;
    memcpy(g2, g1, sizeof g1);
  }
  cout << sum << endl;
  return 0;
}
