#include #include using namespace std; using mint = atcoder::modint1000000007; int main(){ int T, a, b, c, d, e, D; cin >> T >> a >> b >> c >> d >> e; D = max({a, -a, b, -b, c, -c}); vector dp1(20001), dp2(20001); auto dp = dp1.begin() + 10000, ndp = dp2.begin() + 10000; dp[0] = 1; for(int i = 0; i < T; i++){ for(int r = i * D, j = -r; j <= r; j++){ ndp[j - a] += dp[j]; ndp[j + a] += dp[j]; ndp[j - b] += dp[j]; ndp[j + b] += dp[j]; ndp[j - c] += dp[j]; ndp[j + c] += dp[j]; dp[j] = 0; } swap(dp, ndp); } cout << accumulate(dp + d, dp + e + 1, mint(0)).val() << '\n'; }