#include <bits/stdc++.h>
using namespace std;
long long MOD;
int N, C;
int a[1000010];
int P[5010], F[5010];
int dp[5010][5010];
int from[1000010];
int dp2[12000000];
int main(void) {
  int i, j;
  cin >> N >> C >> MOD;
  for ((i) = 0; (i) < (int)(N); (i)++) cin >> a[i];
  P[0] = F[0] = 1;
  for (i = 1; i <= 5000; i++) {
    P[i] = (int)((long long)P[i - 1] * (C + 1 - i) % MOD);
    F[i] = (int)((long long)F[i - 1] * i % MOD);
  }
  dp[1][1] = 1;
  for (i = 1; i < 5000; i++)
    for (j = 1; j <= i; j++) {
      dp[i + 1][j] =
          (int)((dp[i + 1][j] + (long long)dp[i][j] * (j - 1)) % MOD);
      dp[i + 1][j + 1] = (int)((dp[i + 1][j + 1] + dp[i][j]) % MOD);
    }
  for ((i) = 0; (i) < (int)(N - 1); (i)++) from[i + 1] = from[i] + a[i] + 1;
  for ((i) = 0; (i) < (int)(a[0] + 1); (i)++)
    dp2[i] = (int)((long long)dp[a[0]][i] * P[i] % MOD);
  for ((i) = 0; (i) < (int)(N - 1); (i)++) {
    long long sum = 0;
    for ((j) = 0; (j) < (int)(a[i] + 1); (j)++)
      sum = (sum + dp2[from[i] + j]) % MOD;
    for ((j) = 0; (j) < (int)(a[i + 1] + 1); (j)++) {
      long long tmp = (long long)dp[a[i + 1]][j] * P[j] % MOD * sum % MOD;
      if (j <= a[i]) {
        long long tmp2 =
            (long long)dp2[from[i] + j] * F[j] % MOD * dp[a[i + 1]][j] % MOD;
        tmp = (tmp - tmp2 + MOD) % MOD;
      }
      dp2[from[i + 1] + j] = (int)tmp;
    }
  }
  long long ans = 0;
  for ((i) = 0; (i) < (int)(a[N - 1] + 1); (i)++)
    ans = (ans + dp2[from[N - 1] + i]) % MOD;
  cout << ans << endl;
  return 0;
}
