import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Control.Monad.ST
import Data.Array.ST
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [n,k] <- getIntList
    as <- VU.fromList <$> getIntList
    print $ solve n k as

solve n k as = runST $ do
    arr <- newArray ((-1,-1),(n,k)) 0 :: ST s (STUArray s (Int,Int) Int)
    writeArray arr (0,0) 1
    forM_ [0..n] $ \i -> do
        let ai = as VU.! (i-1)
        forM_ [0..k] $ \j -> do
            if i == 0 then
                writeArray arr (0,j) (if j == 0 then 1 else 0)
            else do
                ij1 <- readArray arr (i,j-1)
                i1j <- readArray arr (i-1,j)
                ijm <- readArray arr (i-1, max (j-ai-1) (-1))
                writeArray arr (i,j) $ (ij1 + i1j - ijm) `mod` 1000000007
    readArray arr (n,k)