#include<bits/stdc++.h>
#define ll long long int
const int MOD = 1e9+7;
using namespace std;
int main()
{ ios_base::sync_with_stdio(false); cin.tie(0);
	int n,k;cin>>n>>k;
  ll dpp[k+1]={0};
  dpp[0]=1;
  for(int i=0;i<n;i++)
  { ll curr_lim;cin>>curr_lim;
    ll dp[k+1]={0};
    for(int already=k;already>=0;--already)
    {
         int l=already+1;
         int r=already+min(k-already,curr_lim);
         if(l<=r)
            { dp[l]=(dp[l]+dpp[already+MOD])%MOD;
               if(r+1<=k)
               { dp[r+1]=(dp[r+1]-dpp[already+MOD])%MOD; }
            }
    }
          int pre=0;
        for(int j=0;j<=k;j++)
        {
          pre=(pre+dp[j]+MOD)%MOD;
          dpp[j]=(dpp[j]+pre+MOD)%MOD;
        }
  }
   cout<<dpp[k];
  return 0;
}
