#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <typeinfo>
using namespace std;
#define ll long long 

int main()
{
    ll MOD = 1e9 + 7;
    int n;
    ll k;
    cin >> n >> k;
    ll arr[n];
    for (int i=0; i<n; ++i) {
        cin >> arr[i];
    }
    
    // dp[i][j] is the # of ways to distribute j candies amongst i children.  
    // dp[i][j] += dp[i-1][j-k] for every k ith child can eat.
    ll dp[n+1][k+1]; 
    ll prefix_sum[k+2] = {0}; 
    
    fill(*dp, *dp + (n+1)*(k+1), 0);
    for (int i=0; i<=n; ++i)
        dp[i][0] = 1;
    
    for (int child=1; child<=n; ++child) {
        for (ll i=1; i<=k+1; ++i)
            prefix_sum[i] = (prefix_sum[i-1] + dp[child-1][i-1]) % MOD;

        for (ll c_dist=1; c_dist<=k; ++c_dist) 
            dp[child][c_dist] = prefix_sum[c_dist+1] - prefix_sum[c_dist-min(arr[child-1], c_dist)];
            
    }
    
    cout << dp[n][k];
    return 0;
}
