#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define mod2 998244353
ll exp(ll taban, ll us) {
	if(us < 0) return 0;
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a, b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n, k; cin>>n>>k;
	int dp[k+1] = {};
	dp[0] = 1;
	vector<int> pref(k+2, 1);
	for(int i = 0; i < n; i++){
		int sayi; cin>>sayi;
		for(int j = k; j > 0; j--){
			if(j-sayi-1 >= 0)dp[j] = (dp[j] + pref[j-1] - pref[j - sayi - 1] + mod) % mod;
			else dp[j] = (dp[j] + pref[j-1] + mod) % mod;
		}
		for(int j = 1; j <= k; j++){
			pref[j] = (pref[j-1] + dp[j]) % mod;
		}
	}
	cout<<dp[k]<<endl;
}