#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const long long MOD = 1000000007;

void solve(long long N, long long K, std::vector<long long> a){
    ll dp[N][K+1] = {};
    for(int i=N-1;i>=0;i--){
        for(int j=0;j<=K;j++){
            // cerr << "i=" << i << "j=" <<j << endl;
            if(i == N-1){
                if(j<=a[i]){
                    dp[i][j] =1;
                }
                continue;
            }
            if(j==0){
                dp[i][j] = 1;
                continue;
            }
            if(j<=a[i]){
                dp[i][j] = (dp[i][j-1] + dp[i+1][j])%MOD;
                continue;
            }
            dp[i][j] = (dp[i][j-1] -dp[i+1][j-a[i]-1] +  dp[i+1][j])%MOD;
        }
    }

    // for(int i=N-1;i>=0;i--){
    //     for(int j=0;j<=K;j++){
    //         cerr << "i=" << i << "j=" << j << "val=" << dp[i][j] << endl;
    //     }
    // }

    cout << dp[0][K]%MOD << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, K, std::move(a));
    return 0;
}
