#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
typedef long long ll;
const ll mod = 1e9+7;

int main(){
    ll n, k;
    cin >> n >> k;
    ll a[n];
    rep(i,n) cin >> a[i];
    vector<vector<ll>> dp(n+1, vector<ll>(k+2,0));
    dp[0][k] = 1;
    rep(i,n){
        for(int j = k; j >= 0; j--){
            dp[i+1][j] = (dp[i+1][j+1] + dp[i][j]) % mod;
            if(j+a[i]+1 <= k) (dp[i+1][j] += -dp[i][j+a[i]+1] + mod) %= mod ;
        }
    }
    cout << dp[n][0] << endl;
    return 0;
}