#include <iostream>
#include <string.h>
#include <bits/stdc++.h>
#include<algorithm> 
using namespace std;

int main() {
int N, K;
cin >> N >> K;
int a[N];

for (int i = 0; i < N; ++i)
{
	cin >> a[i];
}

if(N == 1){
	if(a[0] < K) cout << 0 << endl;
	else cout << 1 << endl;
	return 0;
}

long int dp[N][K+1];

for (int i = 0; i < N; ++i)
{
	for (int j = 0; j <= K; ++j)
	{
		dp[i][j] = 0;
	}
}

for (int i = 0; i <= a[0]; ++i)
{
	dp[0][i] = 1;
}

for (int i = 1; i <= K; ++i)
{
	dp[0][i] = (dp[0][i] +  dp[0][i-1])%1000000007;
}

for (int i = 1; i < N; ++i)
{
	for (int j = 0; j <= K; ++j)
	{	
		if(j <= a[i])
		dp[i][j] = (j > 0) ? (dp[i][j-1] + dp[i-1][j])%1000000007 : dp[i-1][j]%1000000007;
		else dp[i][j] = (


			] + dp[i][j-1] + dp[i-1][j]-(dp[i-1][j-1-a[i]]) + 1000000007)%1000000007;
	}
}
if(K != 0)
cout << (dp[N-1][K] - dp[N-1][K-1] + 1000000007)%1000000007<< endl;
else cout << dp[N-1][K]%1000000007 << endl;

return 0;
                                                     
}