//@formatter:off #include #define overload4(_1,_2,_3,_4,name,...) name #define rep1(i,n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,s,n) for (ll i = ll(s); i < ll(n); ++i) #define rep3(i,s,n,d) for(ll i = ll(s); i < ll(n); i+=d) #define rep(...) overload4(__VA_ARGS__,rep3,rep2,rep1)(__VA_ARGS__) #define rrep1(i,n) for (ll i = ll(n)-1; i >= 0; i--) #define rrep2(i,n,t) for (ll i = ll(n)-1; i >= (ll)t; i--) #define rrep3(i,n,t,d) for (ll i = ll(n)-1; i >= (ll)t; i-=d) #define rrep(...) overload4(__VA_ARGS__,rrep3,rrep2,rrep1)(__VA_ARGS__) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define popcount(x) __builtin_popcountll(x) #define pb push_back #define eb emplace_back #ifdef __LOCAL #define debug(...) { cout << #__VA_ARGS__; cout << ": "; print(__VA_ARGS__); cout << flush; } #else #define debug(...) void(0) #endif #define INT(...) int __VA_ARGS__;scan(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;scan(__VA_ARGS__) #define STR(...) string __VA_ARGS__;scan(__VA_ARGS__) #define CHR(...) char __VA_ARGS__;scan(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;scan(__VA_ARGS__) #define LD(...) ld __VA_ARGS__;scan(__VA_ARGS__) using namespace std; using ll = long long; using ld = long double; using P = pair; using LP = pair; using vi = vector; using vvi = vector>; using vl = vector; using vvl = vector>; using vd = vector; using vvd = vector>; using vs = vector; using vc = vector; using vvc = vector>; using vb = vector; using vvb = vector>; using vp = vector

; using vvp = vector>; template istream& operator>>(istream &is,pair &p) { return is >> p.first >> p.second; } template ostream& operator<<(ostream &os,const pair &p) { return os<<'{'< istream& operator>>(istream &is,vector &v) { for(T &t:v){is>>t;} return is; } template ostream& operator<<(ostream &os,const vector &v) { os<<'[';rep(i,v.size())os< void vecout(const vector &v,char div='\n') { rep(i,v.size()) cout< bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;} template bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;} void scan(){} template void scan(Head& head, Tail&... tail){ cin >> head; scan(tail...); } template void print(const T& t){ cout << t << '\n'; } template void print(const Head& head, const Tail&... tail){ cout< void fin(const T&... a) { print(a...); exit(0); } struct Init_io { Init_io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout << boolalpha << fixed << setprecision(15); } } init_io; const string yes[] = {"no","yes"}; const string Yes[] = {"No","Yes"}; const string YES[] = {"NO","YES"}; const int inf = 1001001001; const ll linf = 1001001001001001001; //@formatter:on template class modint { ll x; public: constexpr modint(ll x = 0) : x((x % mod + mod) % mod) {} static constexpr int get_mod() { return mod; } constexpr int val() const { return x; } constexpr modint operator-() const { return modint(-x); } constexpr modint &operator+=(const modint &a) { if ((x += a.val()) >= mod) x -= mod; return *this; } constexpr modint &operator++() { return *this += 1; } constexpr modint &operator-=(const modint &a) { if ((x += mod - a.val()) >= mod) x -= mod; return *this; } constexpr modint &operator--() { return *this -= 1; } constexpr modint &operator*=(const modint &a) { (x *= a.val()) %= mod; return *this; } constexpr modint operator+(const modint &a) const { modint res(*this); return res += a; } constexpr modint operator-(const modint &a) const { modint res(*this); return res -= a; } constexpr modint operator*(const modint &a) const { modint res(*this); return res *= a; } constexpr modint pow(ll t) const { modint res = 1, a(*this); while (t > 0) { if (t & 1) res *= a; t >>= 1; a *= a; } return res; } // for prime mod constexpr modint inv() const { return pow(mod - 2); } constexpr modint &operator/=(const modint &a) { return *this *= a.inv(); } constexpr modint operator/(const modint &a) const { modint res(*this); return res /= a; } }; using modint998244353 = modint<998244353>; using modint1000000007 = modint<1000000007>; template istream &operator>>(istream &is, modint &a) { ll x; is >> x; a = modint(x); return is; } template constexpr ostream &operator<<(ostream &os, const modint &a) { return os << a.val(); } template constexpr bool operator==(const modint &a, const modint &b) { return a.val() == b.val(); } template constexpr bool operator!=(const modint &a, const modint &b) { return a.val() != b.val(); } template constexpr modint &operator++(modint &a) { return a += 1; } template constexpr modint &operator--(modint &a) { return a -= 1; } using mint = modint1000000007; using vm = vector; class combination { vector fact, ifact; public: combination(int n) : fact(n + 1), ifact(n + 1) { fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i; } mint operator()(int n, int k) { if (k < 0 || k > n) return 0; return fact[n] * ifact[k] * ifact[n - k]; } } comb(30000); mint dp[41][41][20010]; int main() { INT(n, mp, mq, l); vi s(n); cin >> s; dp[0][0][0] = 1; rep(i, n) { rep(j, n) { rep(k, mq + 1) { mint now = dp[i][j][k]; if(now.val() == 0) continue; dp[i + 1][j][k] += now; dp[i + 1][j][k + 1] -= now; int mx = min(s[i], mq - (int) k); dp[i + 1][j + 1][k + 1] += now; dp[i + 1][j + 1][k + mx + 1] -= now; } } rep(j, n + 1) rep(k, mq) dp[i + 1][j][k + 1] += dp[i + 1][j][k]; } mint ans = 0; rep(i, n + 1) rep(j, mq + 1) { mint now = dp[n][i][j]; if(now.val() == 0) continue; int rem = mp - (i * l - j); if (rem < 0) continue; ans += now * comb(rem + n - 1, n - 1); } fin(ans); }