program main implicit none integer(8)::g(0:1,-10000:10000),p=1000000007,t,a,b,c,d,e,ans=0,i,j,k,f(3) read*,t read(*,*)a,b,c,d,e f(1)=a f(2)=b f(3)=c do i=0,1 do j=-10000,10000 g(i,j)=0 end do end do g(0,0)=1 do i=1,t do j=-10000,10000 g(mod(i,2),j)=0 end do do j=-10000,10000 if(g(mod(i+1,2),j)==0)cycle do k=1,3 g(mod(i,2),j+f(k))=g(mod(i,2),j+f(k))+g(mod(i+1,2),j) g(mod(i,2),j+f(k))=mod(g(mod(i,2),j+f(k)),p) g(mod(i,2),j-f(k))=g(mod(i,2),j-f(k))+g(mod(i+1,2),j) g(mod(i,2),j-f(k))=mod(g(mod(i,2),j-f(k)),p) end do end do end do do i=d,e ans=mod(ans+g(mod(t,2),i),p) end do print*,ans end program