#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MOD = 1000000007; int main() { int t; cin >> t; vector v(6); for(int i=0; i<3; ++i){ cin >> v[2*i]; v[2*i+1] = -v[2*i]; } int a, b; cin >> a >> b; vector dp(20001, 0); dp[10000] = 1; while(--t >= 0){ vector nextDp(20001, 0); for(int i=0; i<=20000; ++i){ if(dp[i] == 0) continue; for(int j=0; j<6; ++j){ nextDp[i+v[j]] += dp[i]; nextDp[i+v[j]] %= MOD; } } dp.swap(nextDp); } int ans = 0; for(int i=a+10000; i<=b+10000; ++i){ ans += dp[i]; ans %= MOD; } cout << ans << endl; return 0; }