#!/usr/bin/python2 # -*- coding: utf-8 -*- # † from collections import defaultdict mod = 10**9 + 7 T = int(raw_input()) a, b, c, d, e = map(int, raw_input().split()) dp = defaultdict(int) dp[0] = 1 for t in xrange(T): ndp = defaultdict(int) for cur in dp.keys(): ndp[cur + a] += dp[cur] ndp[cur + a] %= mod ndp[cur - a] += dp[cur] ndp[cur - a] %= mod ndp[cur + b] += dp[cur] ndp[cur + b] %= mod ndp[cur - b] += dp[cur] ndp[cur - b] %= mod ndp[cur + c] += dp[cur] ndp[cur + c] %= mod ndp[cur - c] += dp[cur] ndp[cur - c] %= mod dp = ndp res = 0 for r in xrange(d, e+1): res += dp[r] res %= mod print res