#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod=(ll)1e9+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(NULL); cout.tie(NULL); 
  ll n,k,i,j,a;
  cin>>n>>k;
  vector<ll> dp(k+1);
  dp[0]=1;
  
  for(j=0;j<n;j++){
    cin>>a;
    vector<ll> sub(k+1);
    swap(sub,dp);
    for(i=1;i<=k;i++)(sub[i]+=sub[i-1])%=mod;  
    for(i=0;i<=k;i++){
      ll left=i-a-1;
      dp[i]=sub[i];
      if(left>=0)dp[i]-=sub[left];
      (dp[i]+=mod)%=mod;
    }
    
  }
  cout<<dp[k];
}