#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int mod;
long long xx[5555], c[5555];
long long a[5555][5555];
long long dp[2][5555];
long long n, m, l;
long long ans, sum, last_sum, p;
int main() {
  cin >> n >> m >> p;
  xx[0] = 1;
  for (long long i = 1; i < 5555; i++) {
    xx[i] = xx[i - 1] * (m - i + 1) % p;
  }
  c[0] = 1;
  for (long long i = 1; i < 5555; i++) {
    c[i] = c[i - 1] * i % p;
  }
  a[0][0] = 1;
  for (long long i = 1; i < 5001; i++) {
    for (long long j = 1; j < min(m, i) + 1; j++) {
      a[i][j] = ((j - 1) * a[i - 1][j] % p + a[i - 1][j - 1]) % p;
    }
  }
  cin >> l;
  long long pos = 0;
  sum = last_sum = 0;
  for (long long j = 1; j < min(m, l) + 1; j++) {
    dp[pos][j] = xx[j] * a[l][j] % p;
    last_sum = (last_sum + dp[pos][j]) % p;
  }
  pos ^= 1;
  for (long long i = 1; i < n; i++) {
    memset(dp[pos], 0, sizeof(dp[pos]));
    scanf("%d", &l);
    sum = 0;
    for (long long j = 1; j < min(m, l) + 1; j++) {
      dp[pos][j] = ((last_sum * a[l][j] % p * xx[j] % p) -
                    (c[j] * dp[pos ^ 1][j] % p * a[l][j] % p)) %
                   p;
      sum = (sum + dp[pos][j]) % p;
    }
    last_sum = sum;
    pos ^= 1;
  }
  cout << (last_sum + p) % p << endl;
  return 0;
}
