#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define endl "\n"
#define PI 3.14159265
const int mod=1e9+7;
//const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    int dp[n+1][k+1];
    int pre[n+1][k+1];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=0;


            if(j==0){dp[i][j]=1;pre[i][j]=dp[i][j];continue;}
            if(i==0){dp[i][j]=0;pre[i][j]=1;continue;}

            /*  for(int k=0;k<=min(a[i-1],j);k++)
              {
              //    dp[i][j]+=dp[i-1][j-k];
              }*/
              //int d=min(a[i-1],j);
              dp[i][j]=(pre[i-1][j]%mod-((j-d-1)>=0?pre[i-1][j-d-1]:0)%mod)%mod;

              //if(j==0);
               pre[i][j]=(pre[i][j-1]%mod+dp[i][j]%mod)%mod;
        }
    }
   /* for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }
    cout<<endl;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            cout<<pre[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<dp[n][k]%mod<<endl;

    return 0;
}
