using System; using static System.Console; using System.Linq; using System.Collections.Generic; using AtCoder; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var s = NList; var a = Math.Abs(s[0]); var b = Math.Abs(s[1]); var c = Math.Abs(s[2]); var dp = new long[20001]; var ndp = new long[20001]; var mod = 1_000_000_007; var offset = 10000; dp[offset] = 1; for (var i = 0; i < t; ++i) { for (var j = 0; j < ndp.Length; ++j) ndp[j] = 0; for (var j = 0; j < dp.Length; ++j) { if (j - a >= 0) ndp[j - a] += dp[j]; if (j - b >= 0) ndp[j - b] += dp[j]; if (j - c >= 0) ndp[j - c] += dp[j]; if (j + a < ndp.Length) ndp[j + a] += dp[j]; if (j + b < ndp.Length) ndp[j + b] += dp[j]; if (j + c < ndp.Length) ndp[j + c] += dp[j]; } for (var j = 0; j < ndp.Length; ++j) dp[j] = ndp[j] % mod; } var ans = 0L; for (var i = s[3] + offset; i <= s[4] + offset; ++i) ans = (ans + dp[i]) % mod; WriteLine(ans); } }