/*

    author : Divyansh Gupta

*/

#include <iostream>

#include <iomanip>

#include <cstring>

#include <vector>

#include <algorithm>

#include <stack>

#include <queue>

#include <utility>

#include <map>

using namespace std;

void print_err() {

	cerr<<"\n";}

template <class T,class... Arg>

void print_err(T x,Arg&&... args) {

	cerr<<x<<" ";

	print_err(args...);

}

#ifdef local

#define debug(...) print_err(__VA_ARGS__)

#else

#define debug(...)

#endif

#define test_case int test_cases;\

                cin>>test_cases;\

                while(test_cases--)

#define lu(var,l,r) for(var=l;var<r;var++)

#define ld(var,r,l) for(var=r;var>=l;var--)

#define ll long long

#define mp make_pair

#define pb push_back

#define vi vector<int>

#define vvi vector<vector<int> >

#define vll vector<ll>

#define vvll vector<vector<ll> >;               	

#define pii pair<int,int>                	

#define br cout<<"\n"

#define sp cout<<" "

#define pr cout<<

#define in cin>>

#define f first

#define s second                    

#define mod 1000000007

            

void solve(){

	int n,k,i,j,x,l;

	ll ans;

	vi A;

	in n;

	in k;

	A.pb(0);

	lu(i,0,n) {

		in x;

		A.pb(x);

	}

	int dp[n+1][k+1];

	lu(i,0,k + 1) {

		dp[0][i] = 1;

	}

	lu(i,0,n) {

		dp[i][0] = 1;

	}

	lu(i,1,n) {

		lu(j,1,k + 1) {

			ans = 0ll;

			if(j - A[i] > 0) {

				ans = mod+dp[i-1][j] - dp[i - 1][j - A[i] - 1];

			} else {

				ans = dp[i-1][j];

			}

			dp[i][j] = (ans + dp[i][j-1])%mod;

		}

	}

	ans = 0;

	if(k - A[n] > 0) {

		ans = mod+dp[n-1][k] - dp[n - 1][k - A[n] - 1];

	} else {

		ans = dp[n-1][k];

	}

	pr ans%mod;

	br;

}

int main(){

    solve();

    return 0;

}