#include #include #include using namespace std; // 20 * 500 * 2 const long long mod = 1e9 + 7; long long dp[501][22020]; void to(long long &x, long long y) { x += y; if (x >= mod) x -= mod; } int main() { int n; cin >> n; int a, b, c, d, e; cin >> a >> b >> c >> d >> e; dp[0][10000] = 1; for (int i = 0; i < n; i++) { for (int j = 50; j < 20000; j++) { to(dp[i + 1][j + a], dp[i][j]); to(dp[i + 1][j - a], dp[i][j]); to(dp[i + 1][j + b], dp[i][j]); to(dp[i + 1][j - b], dp[i][j]); to(dp[i + 1][j + c], dp[i][j]); to(dp[i + 1][j - c], dp[i][j]); } } long long ans = 0; for (int i = 10000 + d; i <= 10000 + e; i++) { to(ans, dp[n][i]); } cout << ans << endl; }