#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
 
int main(){
	int n,k;
	cin>>n>>k;
	int a[n+5];
	for(int i=1; i<=n; i++) cin>>a[i];
	int dp[n+5][k+5]; //nth element k used
	memset(dp,0,sizeof(dp));
	dp[0][0] = 1;
	for(int i=1; i<=n; i++){
		int sm=0;
		for(int j=0; j<=k; j++){
			if(j<=a[i]) sm+=dp[i-1][j];
			else {
				sm-=dp[i-1][j-a[i]-1];
				sm+=dp[i-1][j];
			}
			sm %= MOD;
			if(sm < 0) sm+=MOD;
			dp[i][j] = sm;
		}
	}
	cout<<dp[n][k];
}