#include <bits/stdc++.h>

using vll = std::vector<long long>;
constexpr long long mod{1000000007};

int main()
{
	int n, k;
	scanf("%d%d", &n, &k);
	std::vector<vll> combi(n + 1, vll(k + 1));
	combi[0][0] = 1;
	for (int n_i{1}; n_i <= n; n_i++)
	{
		int a;
		scanf("%d", &a);
		long long sum{};
		for (int k_i{}; k_i <= k; k_i++)
		{
			sum += combi[n_i - 1][k_i];
			sum %= mod;
			if (k_i - a - 1 >= 0)
			{
				sum += mod - combi[n_i - 1][k_i - a - 1];
				sum %= mod;
			}
			combi[n_i][k_i] = sum;
		}
	}
	printf("%lld\n", combi[n][k]);

	return 0;
}