{-# LANGUAGE BangPatterns      #-} --引数に!
{-# LANGUAGE MultiWayIf        #-}
{-# LANGUAGE TupleSections     #-}

import Data.List
import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.ST
import Data.Vector.Unboxed as V ((!),fromList,Vector)
import Control.Monad
import Control.Monad.ST
import Debug.Trace

type DP s = STUArray s (Int,Int) Int

dp_i :: DP s-> Int -> Int -> Int -> Int -> Int -> ST s ()
dp_i dparr ai k i j prevsum
  | j < 0 = return ()
  | j >= k-ai = do
    hand0 <- readArray dparr (i-1,j)
    let nowsum = hand0 + prevsum
    writeArray dparr (i,j) nowsum
    dp_i dparr ai k i (j-1) nowsum
  | otherwise = do
    hand0  <- readArray dparr (i-1,j)
    handai <- readArray dparr (i-1,j+ai+1)
    let nowsum = hand0 + prevsum - handai
    writeArray dparr (i,j) nowsum
    dp_i dparr ai k i (j-1) nowsum

solve :: Int -> Int -> Vector Int -> ST s Int
solve n k as = do
  dparr <- newArray ((0,0),(n,k)) 0
  writeArray dparr (0,k) 1
  forM_ [1..(n-1)] $ \i ->
    dp_i dparr (as V.! (i-1)) k i k 0
  ans0 <- forM [0..(as V.! (n-1))] $ \j -> readArray dparr (n-1,j)
  return $ sum ans0

main :: IO ()
main = do
  [n,k]  <- map read.words <$> getLine
  as <- map read.words <$> getLine
  putStrLn $ show $ mod0 $ max 0 $ runST $ solve n k (V.fromList as)

-------------------------
mod0 :: Int -> Int
mod0 n = mod n 1000000007
