#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007;
vector<vector<int>>dp; // dp(i,j) ways when i children and ith children get j candies
vector<int>v;

int ways(int n,int candies){
    //cout<< n<<" "<<candies<<"\n";
    //int q;cin>>q;
    if(dp[n][candies]  != -1){
        return dp[n][candies];
    }
    int ans=0;
    ans = (ways(n,candies-1) + ways(n-1,candies))%mod;
    if(candies>=(v[n]+1)){
        ans -= ways(n-1,candies-v[n]-1);
        ans %=mod;
    }
    return dp[n][candies] =ans;

}

void solve(){
    int n,k;cin>>n>>k;
    dp.resize(n,vector<int>(k+1,-1));
    v.resize(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    int x = min(v[0],k);
    for(int i=0;i<=x;i++){
        dp[0][i]=1;
    }
    for(int i=x+1;i<=k;i++){
        dp[0][i]=0;
    }
    for(int i=0;i<n;i++){
        dp[i][0]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<=k;j++){
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%mod
            if(j>= (v[i]+1)){
                dp[i][j] = (mod + dp[i][j] - dp[i-1][j-v[i]-1])%mod;
            }
        }
    }
    cout<<dp[n-1][k]<<"\n";


}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);

    cout.precision(10);
    int t=1;//cin>>t;
    while(t--){

        solve();
    }
    return 0;
}
