#include<bits/stdc++.h>
using namespace std;
const long long int mod=1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int i,j,k,a,b,low=1,high,ans=0,l,r,n,h,q,ch,x,u,sum=0;
  cin >> n >> k;
  long long int arr[n+1];
  for(i=1;i<=n;i++)
  {
    cin >> arr[i];
    sum+=arr[i];
  }
  long long int dp[n+1][k+1]={0},ar[n+1]={0};
  for(i=1;i<=n;i++)
    dp[i][0]=ar[i]=1;
  for(i=0;i<=k;i++)
    dp[0][i]=0;
  arr[0]=0;
  //cout << sum << endl;
  if(sum<k)
    cout << "0" << endl;
  else
  {
    for(i=1;i<=n;i++)
      for(j=1;j<=k;j++)
      {
        if(j<=arr[i])
        {
          dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
        }
        else
        {
          ar[i-1]=((ar[i-1]-dp[i-1][j-arr[i]-1])%mod+mod)%mod;
          dp[i][j]=ar[i-1];
        }
        ar[i]=(ar[i]+dp[i][j])%mod;
        //cout << i << " " << j << dp[i][j] << endl;  
      }
    /*for(i=0;i<=n;i++)
      {
        for(j=0;j<=sum;j++)
          cout << dp[i][j] << " ";
        cout << endl;
      }*/
    for(i=1;i<=n;i++)
    {
      ans=max(ans,dp[i][k]);
    }
    cout << ans << endl;
  }    
  return 0;
}