local mod = 1000000007
local function badd(x, y) return (x + y) % mod end
local function bsub(x, y) return y <= x and x - y or x + mod - y end
local n, k = io.read("*n", "*n")
local dp1, dp2 = {1}, {0}
for i = 2, k + 1 do
  dp1[i] = 0
  dp2[i] = 0
end
for i = 1, n do
  local src = i % 2 == 1 and dp1 or dp2
  local dst = i % 2 == 1 and dp2 or dp1
  for j = 1, k + 1 do
    dst[j] = 0
  end
  local a = io.read("*n") + 1
  local sum = 0
  for j = 1, k + 1 do
    sum = badd(sum, src[j])
    if a < j then
      sum = bsub(sum, src[j - a])
    end
    dst[j] = badd(dst[j], sum)
  end
end
local ret = n % 2 == 1 and dp2 or dp1
print(ret[k + 1])
