N,K,*A = `dd`.split.map &:to_i
Mod = 1e9.to_i+7
dp = Array.new(K+1,0)
sp = Array.new(K+2,0)
sp[1] = dp[0] = 1
(0...N).each{ |i|
  a = A[i]
  q = sp[1]
  (1..K).each{ |k|
    sp[k+1] = q += dp[k]
    m = k-a > 0 ? k-a : 0
    dp[k] = (q - sp[m]) % Mod
  }
}
p dp[-1]
