#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<unordered_map>
#include<set>
#include<cmath>
#include<random>

//#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define ALL(v) (v).begin() , (v).end()
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long
const int mod = 1e9 + 7;
void solve(){

	int n , k;
	cin>>n>>k;
	int a[n];
	for(int i = 0 ;  i < n ; ++i)
		cin>> a[i] ;

	int dp[k+2];
	memset(dp , 0 , sizeof dp);
	dp[0] = 1;
	for(int i = 0 ; i < n ; ++i){

		int x = a[i];
		int tmp[k+2];
		memset(tmp , 0 , sizeof tmp);
		for(int j = k ; j >= 0 ; --j){

			int val = dp[j];
			int left = j + 1;
			int right = j + x;
			right = min(right , k);

			tmp[left] += val;
			tmp[right + 1]-=val;
		}

		for(int j = 1 ; j <= k ; ++j){

			tmp[j] += tmp[j-1];
			dp[j] += tmp[j];
			dp[j]%=mod;
		}
	}

	cout<<dp[k]<<endl;
}

signed main(){

    fast;
    //freopen("output.txt" , "w" , stdout);
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}
