import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Queue, PriorityQueue}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val a = new Array[Int](N+1)
  for (i <- 1 to N)
    a(i) = in.next().toInt


  //
  val MOD = 1e9.toInt + 7
  val dp = Array.ofDim[Long](N+2, K+2)
  dp(0)(0) = 1

  for (i <- 1 to N) {
    for (j <- 1 to K) {
      dp(i-1)(j) += dp(i-1)(j-1)
      dp(i-1)(j) %= MOD
    }

    val now = a(i)
    for (k <- 0 to now) {
      dp(i)(k) = dp(i-1)(k)
      dp(i)(k) %= MOD
    }
    for (k <- now+1 to K) {
      dp(i)(k) = dp(i-1)(k) - dp(i-1)(k-(now+1))
      dp(i)(k) %= MOD
    }
  }

  println(dp(N)(K))
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
