#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include<unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include<bits/stdc++.h>
#include<deque> 
#include<bitset>
#include<string>
#define N 1e6
#define K 300005
#define MOD 1e9+7
#define int long long 
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
 
int max(int a, int b){
    if(a>b)
        return a;
    return b;
}
int min(int a, int b){
    if(a<b)
        return a;
    return b;
}
 
int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

int mod = 1e9 + 7;

int32_t main(){
	// int n, k;
	// cin>>n>>k;
	// int a[n+1];
	// for(int i=1;i<=n;i++){
	// 	cin>>a[i];
	// }
	// //no of ways with k stones and upto ith person
	// int dp[n+1][k+1];
	// for(int i=0;i<=n;i++){
	// 	dp[i][0] =1;
	// }
	// for(int i=1;i<=n;i++){
	// 	for(int st = 1; st<=k; st++){
	// 		int ans = 0;
	// 		for(int v = 0; v<= a[i] && st - v >=0; v++){
	// 			ans += dp[i-1][st - v];
	// 			if(ans > mod)
	// 				ans -= mod;
	// 		}
	// 		dp[i][st] = ans;
	// 	}
	// }
	// cout<<dp[n][k]<<endl;
	
	int n, k;
	cin>>n>>k;
	int a[n+1];
	a[0] = 0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
    int dp[k+1];
    //0 stones and 0 children initially so 1 way is nothin
	dp[0] = 1;
    //for more than 1 stones but no children there is no way
    for(int i=1;i<=k;i++)
        dp[i] = 0;
	//ex if we have 4 stone and the cap on the last person is 3
	//dp[4] will appear in the foll terms dp[5] -- when last person eats 1
	//dp[6] when last person eats 2
	//dp[7] when last person eats 3
	for(int c = 1; c<=n;c++){//for each subsequent child
		int lim = a[c]; //the last child can be awarded 1...lim candies
		int temp[k+2] = {0};
		for(int st = 0; st <= k; st++){//we are seeing which stone influnces which answer
			int lo = st + 1;
			int hi = min(k, st + lim);
			temp[lo] += (dp[st]);
            if(temp[lo] > mod)
                temp[lo] -= mod;
			temp[hi + 1] -= (dp[st]);
            temp[hi + 1] += mod;
            if(temp[hi + 1] > mod)
                temp[hi + 1] -= mod;
		}
		//prefix sum
		int sum = 0;
		for(int i=0;i<=k;i++){
			sum += temp[i];
            if(sum > mod)
                sum -= mod;
			dp[i] += sum;
            if(dp[i] > mod)
                dp[i] -= mod;
		}
	}
	cout<<dp[k]<<endl;


	
}









