#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  
#include <numeric>
#include <sys/resource.h>
 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define endl '\n'
using ll = long long;
 
const int precision = 15;
const int modulo =  1000000007; // 10^9 + 7
const ll lmodulo =  1000000007; // 10^9 + 7
 
const double EPS = 1e-9;
const ll inf = 1e18;


void increaseStack() {
	const rlim_t kStackSize = 50 * 1024 * 1024;   // min stack size = 50 MB
	struct rlimit rl;
	int result;

	result = getrlimit(RLIMIT_STACK, &rl);
	if (result == 0) {
		if (rl.rlim_cur < kStackSize) {
			rl.rlim_cur = kStackSize;
		    result = setrlimit(RLIMIT_STACK, &rl);
		    if (result != 0) {
		    	fprintf(stderr, "setrlimit returned result = %d\n", result);
		    }
		}
	}
}


void solve() {
	int n, k; cin >> n >> k;
	vector<int> candies(n);
	for (auto &it : candies) {
		cin >> it;
	}

	vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));

	dp[0][0] = 1;
	for (auto i = 1; i <= n; ++i) {
		auto candy = candies[i - 1];
		for (auto j = 1; j <= k; ++j) {
			dp[i - 1][j] += dp[i - 1][j - 1];
			dp[i - 1][j] %= lmodulo;
		}

		for ( auto v = 0; v <= k; ++v) {
			ll minV = v - candy > 0 ? dp[i - 1][v - candy - 1] : 0;
			dp[i][v] += dp[i - 1][v] - minV;
			dp[i][v] %= lmodulo;
		}
	}
	cout << dp[n][k];
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  solve();
  return 0;
}
