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

#define ff first
#define ss second
#define endl '\n'
#define int ll

const int MOD = 1e9 + 7;

main()
{
	ios::sync_with_stdio(0); cin.tie(0);

	int n, k;
	cin >> n >> k;

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

	if (accumulate(a, a+n, 0) < k) {
		cout << 0 << endl;
		return 0;
	}

	int dp[k+1][n];
	memset(dp, 0, sizeof(dp));
	for (int i = 0; i <= a[0]; ++i) {
		dp[i][0] = 1;
	}

	int p = 0;
	for (int c = 1; c < n; ++c) {
		p = 0;

		for (int r = 0; r <= a[c]; ++r) {
			dp[r][c] = (p + dp[r][c-1]) % MOD;
			p = (p + dp[r][c-1]) % MOD;
		}
	}

	cout << dp[a[n-1]][n-1] << endl;
	return 0;
}