#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const long long MOD  = 1e9 +7;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	ll n,k;
	cin >>n>>k;
	vector<int> v(n+1);
	for(int i = 0;i < n; i++) cin >> v[i];
	vector<vector<ll>> dp(n+1,vector<ll>(k+1));
	vector<ll> end(k+1);
	ll ans = 0;
		dp[0][0]  = 1;
	for(int i = 0, m;i < n; i++) {
		 ans  = 0;
		 for(int j = 0;j <= k;j++) {
			 ans = ans+dp[i][j];
			 if(ans>=MOD) ans = ans - MOD;
		 	 m = min(j + v[i],k);
		 	 end[m] = dp[i][j];
		 	 dp[i+1][j] = ans;
		 	 ans = ans - end[j];
		 	 end[j] = 0;
		 }
	}

	cout <<dp[n][k]<<'\n';
	return 0;
}