#include <iostream>
#include <vector>

using namespace std;

#define MOD 1000000007

int main() {
	int n, k; cin >> n >> k;
	vector<vector<long long> > dp(n + 1, vector<long long>(k + 1));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		long long sum = 0;
		for (int j = 0; j <= k; ++j) {
			sum += dp[i][j];
			if (j > a) sum -= dp[i][j - a - 1];
			dp[i + 1][j] = sum % MOD;
		}
	}
	cout << dp[n][k] << endl;

	return 0;
}