#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
using namespace std;

int main()
{
	int n, K;
	cin >> n >> K;

	int a[n];
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	ll dp[n][K+1];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i < K+1 and a[0] >= i; ++i)
		dp[0][i] = 1;

	for (int i = 1; i < n; ++i)
	{
		ll sum = 0;
		for (int j = 0; j <= K; ++j)
		{
			if(j-a[i]-1 >= 0)
				sum = (sum - dp[i-1][j-a[i]-1] + MOD)%MOD;
			sum = (sum + dp[i-1][j])%MOD;

			dp[i][j] = (dp[i][j] + sum)%MOD;
		}
	}
	
	cout << dp[n-1][K];
	return 0;
}