import java.util.*; public class Main { static final int MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int[] arr = new int[3]; int count = 0; int max = 0; for (int i = 0; i < 3; i++) { arr[i] = Math.abs(sc.nextInt()); } int d = sc.nextInt(); int e = sc.nextInt(); int[][] dp = new int[t + 1][20002]; dp[0][10001] = 1; for (int i = 0; i < t; i++) { for (int j = 0; j < dp[i].length; j++) { for (int x : arr) { if (j - x >= 0) { dp[i + 1][j - x] += dp[i][j]; dp[i + 1][j - x] %= MOD; } if (j + x < dp[i].length) { dp[i + 1][j + x] += dp[i][j]; dp[i + 1][j + x] %= MOD; } } } } int total = 0; for (int i = d + 10001; i <= e + 10001; i++) { total += dp[t][i]; total %= MOD; } System.out.println(total); } }