#include<bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
int main(){
	int n,k; cin >> n >> k;
	vector<int> dp(k+1); dp[0] = 1;
	for(int i = 0; i < n; i++){
		int c; cin >> c;
		vector<int> pfx(k+1);
		for(int cur = k; cur >= 0; cur--){
			int rb = min(k - cur, c);
			if(rb < 1) continue;
			(pfx[cur + 1] += dp[cur]) %= p;
			if(cur + rb + 1 <= k) (pfx[cur + rb + 1] -= dp[cur] - p) %= p;
		}
		for(int i = 1; i <= k; i++) (pfx[i] += pfx[i-1]) %= p, (dp[i] += pfx[i]) %= p;
	}
	cout << dp[k] << endl;
}