import strutils, sequtils

let MOD = 1_000_000_000+7
type SegmentTree = object
  n: int
  dat: seq[int]
proc initSegmentTree(sz: int): SegmentTree =
  var n = 1
  while n<sz: n*=2
  var dat = newSeqWith(n*2-1, 0)
  result = SegmentTree(n: n, dat: dat)
proc upd(this: var SegmentTree, i, x: int) =
  var k = i+this.n-1
  this.dat[k] = x
  while k>0:
    k = (k-1) div 2
    this.dat[k] = (this.dat[k*2+1]+this.dat[k*2+2]) mod MOD
proc rsum(this: SegmentTree, ql, qr, i, il, ir: int): int =
  if qr<=il or ir<=ql:
    result = 0
  elif ql<=il and ir<=qr:
    result = this.dat[i]
  else:
    let m = (il+ir) div 2
    result = (
      this.rsum(ql, qr, i*2+1, il, m)+this.rsum(ql, qr, i*2+2, m, ir)) mod MOD

proc main() =
  let
    nk = stdin.readLine.split.map(parseInt)
    (n, k) = (nk[0], nk[1])
    a = stdin.readLine.split.map(parseInt)
  var tree = initSegmentTree(k+1)
  tree.upd(0, 1)
  for x in a:
    for rj in 0..k:
      let
        j = k-rj
        res = tree.rsum(max(0, j-x), j+1, 0, 0, tree.n)
      tree.upd(j, res)
  echo tree.rsum(k, k+1, 0, 0, tree.n)
main()
