#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll mod=1e9+7;
int main(){
	ll n,k;
	cin>>n>>k;
	ll dp[k+1]={0};
	
	dp[0]=1;
	for(int i=0;i<n;i++){
		ll a;
		cin>>a;
		ll prefix[k+1]={0};
		for(int used=k;used>=0;used--){
			ll temp=dp[used];
			ll l=used+1;
			ll r=used+min(a,k-used);
			if(l<=r){
				prefix[l]+=temp;
				prefix[l]%=mod;
				if(r+1<=k){
				prefix[r+1]+=-temp;
				prefix[r+1]%=mod;
				}
			}
			
		}
		ll ps=0;
		for(int j=0;j<=k;j++){
			p+=prefix[j];
			p%=mod;
			dp[j]+=p;
			dp[j]%=mod;
		}
	}
	cout<<dp[k];
}