#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define here(x) cout << " #x = " << x << endl;
#define show(x) {for( auto ii : x) cout << ii << setw(4); cout << endl;}
#define shop(n,x) {for(int i = 0; i < n; i++) cout << x << setw(4); cout << endl;}
#define ff first
#define ss second
#define sq(x) (x*x)
#define endl '\n'
#define en " "
#define pb push_back
#define mpair make_pair
ll mod=1000000007;
double pi=3.1415926536;
int main()
{
	fastio();
	int tt = 1;
	//cin >> tt;
	while(tt--)
	{
		// go fast 		check		//		CHECK -> if()   else if()
		
		ll n, x=0, m=0, y=0, d=1, k=mod;
		cin >> n >> k;
		ll a[n + 1] = {};
		ll dp[n + 1][k + 1] = {};	
		dp[0][0] = 1;	
		for(ll i = 1; i <= n; i++)
		{
			cin >> a[i];
			dp[i][0] = 1;
		}
		for(ll i = 1; i <= n; i++)
		{
			x = 1;
			for(ll j = 1; j <= k; j++)
			{
				if(j - a[i] >= 1)
					x += dp[i - 1][j] - dp[i - 1][j - a[i] - 1];
				else
					x += dp[i - 1][j];
				x = x % mod;
				dp[i][j] = x;
			}
		}
		// shop(k + 1, i);
		// for(ll i = 0; i <= n; i++)
		// 	show(dp[i])
		cout << dp[n][k] << endl;
	}
}