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

#define int long long int
#define mod 1000000007

signed main()
{
    int n,i,k,g,j;
    cin>>n>>k;
    int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int dp[k+1];
    int psum[k+1]={0};
    for(i=0;i<n;i++) dp[i]=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<=k;j++)
        {
            if(j==0) {dp[j]=1;psum[0]=dp[0];continue;}
            if(i==0) {
            if(j<=a[i]) dp[j]=1;
            else dp[j]=0;
            }
            else
            {
                dp[j]=psum[j];
                if(j-a[i]-1>=0) dp[j]=((dp[j]%mod)-(psum[j-a[i]-1]%mod) + mod)%mod;
            }
            psum[j]=((dp[j]%mod)+(psum[j-1]%mod))%mod;
        }
    }
    cout<<dp[k]%mod;
}
