#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;

int N,K,A[101010];
ll to[101010], from[101010];

int main(){
  cin>>N>>K;
  rep(i,N) cin>>A[i];
  from[0]=1;
  rep(i,N){
    fill(to,to+101010,0);
    for(int j=0;j<=K;j++){
      int k=min(K+1,j+A[i]+1);
      (to[j]+=from[j])%=MOD;
      to[k]=(to[k]-from[j]+MOD)%MOD;
    }
    rep(j,K) (to[j+1]+=to[j])%=MOD;
    swap(from,to);
  }
  cout<<from[K]<<endl;
  return 0;
}
