package main

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

const MOD = 1000000007

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N, K int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &K)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	dp := make([][]int, N+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, K+1)
	}

	for i := 0; i <= N; i++ {
		dp[i][0] = 1
	}
	for i := 1; i <= N; i++ {
		for k := 1; k <= K; k++ {
			v := (dp[i][k-1] + dp[i-1][k]) % MOD
			if k-as[i-1]-1 >= 0 {
				v = (v - dp[i-1][k-as[i-1]-1]) % MOD
			}
			dp[i][k] = v
		}
	}
	fmt.Println(dp[N][K])

	/*
		// for debug
		for i := 1; i <= N; i++ {
			for k := 0; k <= K; k++ {
				fmt.Print(dp[i][k], ", ")
			}
			fmt.Println()
		}
	*/
}
