package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func main() {
	mod := 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	k := intScanner()
	as := make([]int, n)
	for i := 0; i < n; i++ {
		as[i] = intScanner()
	}
	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, k+1)
	}
	dp[0][0] = 1
	for i := 1; i < n+1; i++ {
		s := make([]int, k+1)
		s[0] = dp[i-1][0]
		for j := 1; j < k+1; j++ {
			s[j] = (s[j-1] + dp[i-1][j]) % mod
		}
		for j := 0; j < k+1; j++ {
			if j-as[i-1] <= 0 {
				dp[i][j] = s[j]
			} else {
				dp[i][j] = (s[j] - s[j-as[i-1]-1]) % mod
			}
		}
	}
	fmt.Println(dp[n][k])
}
func larger(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}
