#include #include using namespace std; using namespace atcoder; using mint = modint; using ll = long long; using VL = vector; struct COMB_MOD { ll mod; int MAX; VL fac, finv, inv; COMB_MOD(int max, ll m) { fac.assign(max, 0); finv.assign(max, 0); inv.assign(max, 0); mod = m; MAX = max; } void solve() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod%i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } ll comb(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } }; int main() { mint::set_mod((ll)1e9 + 7); int N, M, MP, MQ, L; cin >> N >> MP >> MQ >> L; vector> dp(N + 1, vector(MQ + 1, 0)); dp[0][0] = 1; vector> sdp(N + 1, vector(MQ + 1, 0)); for (int i = 0;i <= MQ;i++) sdp[0][i] = 1; for (int i = 1;i <= N;i++) { int s;cin >> s; vector> ndp(N + 1, vector(MQ + 1, 0)); vector> nsdp(N + 1, vector (MQ + 1, 0)); for (int j = 0;j <= N;j++) for (int k = 0;k <= MQ;k++) { ndp[j][k] += dp[j][k]; if (k == 0) { nsdp[j][k] += ndp[j][k]; } else { nsdp[j][k] = nsdp[j][k - 1] + ndp[j][k]; } if (j == 0 or k == 0) continue; int l = k - min(s, k);int r = k - 1; ndp[j][k] += sdp[j - 1][r] - (l == 0 ? 0 : sdp[j - 1][l - 1]); nsdp[j][k] = nsdp[j][k - 1] + ndp[j][k]; } swap(dp, ndp); swap(sdp, nsdp); } COMB_MOD comb(MP + MQ + N + 100, (ll)(1e9 + 7)); comb.solve(); mint ans = 0; for (int m = 0;m <= MQ;m++) for (int n = 0;n <= N;n++) { int R = MP - (L * n) + m; ans += mint(comb.comb(R + N - 1, N - 1)) * dp[n][m]; } cout << ans.val() << endl; }