#include <bits/sdtc++.h>
using namespace std;
#define ll long long
ll mod = 1e9 + 7;
int main()
{




	ll n, k;

	std::cin >> n >> k;
	ll arr[n];
	for (int i = 0; i < n; ++i)
	{
		std::cin >> arr[i];

	}


	ll dp[n + 1][k + 1];
	memset(dp, 0, sizeof dp);

	for (int i = 1; i <= k; i++)
	{	dp[1][i] = (arr[0] < i) ? 0 : 1;
	}


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

	for (int i = 2; i <= n; i++)
	{

		for (int j = 1; j <= k; j++)
		{

			if (j - arr[i - 1] <= 0)
			{
				dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
				dp[i][j] = (dp[i][j] + mod) % mod;
			} else
			{
				dp[i][j]  = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - arr[i - 1]];
				dp[i][j] = (dp[i][j] + mod) % mod;
			}


		}

	}

	// for (int i = 0; i <= n; i++)
	// {

	// 	for (int j = 0; j <= k; j++)
	// 	{
	// 		cout << dp[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }



	cout << (dp[n][k] + mod) % mod;


	return 0;
}