program atcoder
    implicit none
    integer(8) :: i,j,n,k,modd
    integer(8),allocatable,dimension(:,:) :: dp
    integer(8),allocatable,dimension(:) :: a
    read*,n,k
    allocate(dp(0:n,0:k))
    allocate(a(0:n))
    read(*,*)(a(i),i=1,n)
    modd = 1000000007
    do i = 0,n
        dp(i,0) = 1
    enddo
    do i = 1,n
        do j = 1,k
            if(j-a(i)-1 >= 0 ) then
                dp(i,j) = dp(i,j-1)+dp(i-1,j)-dp(i-1,j-a(i)-1)
            else
                dp(i,j) = dp(i,j-1)+dp(i-1,j)
            end if
            dp(i,j) = mod(mod(dp(i,j),modd)+modd,modd)
        enddo
    enddo
    write(*,'(I0)')dp(n,k)
    stop 
!---------------------------------------
contains

end program atcoder
