import strutils,algorithm, sequtils, math

let get = iterator: string{.closure.}=
  for s in stdin.readLine.split:yield s

proc read:int = get().parseInt

const d = (1E9+7).int

proc solve(n,mk:int,takea:seq[int]):int=
  var dp = newseqwith(n+1,newseqwith(mk+1,0))
  for nidx in 0..n:
    dp[nidx][0] = 1

  for nidx in 1..n:
    for k in 1..mk:
      #echo nidx, "段, ", k, "個目, ", takea[nidx-1], "個, ", k<=takea[nidx-1]
      if k <= takea[nidx-1]:
        dp[nidx][k] = (dp[nidx][k-1]+dp[nidx-1][k]) mod d
      else:
        #echo dp[nidx][k-1], " - ", dp[nidx-1][k-takea[nidx-1]-1], " + ", dp[nidx-1][k]
        dp[nidx][k] = (  dp[nidx][k-1] - dp[nidx-1][k-takea[nidx-1]-1] + dp[nidx-1][k] ) mod d
      #for d in dp:
        #echo d
    
  return dp[n][mk]


var
  n,k = read()
  an = stdin.readline.split.mapIt(it.parseInt)

echo solve(n,k,an)
