#include<bits/stdc++.h>
#define int long long
using namespace std;
int n, K;
const int M = 1e9+7, ms = 2e5+9;
int dp[ms], a[ms], pre[ms];
main(){
  cin >> n >> K;

  for(int i = 0; i < n; i++) cin >> a[i];
  
  dp[0] = 1;
  for(int i = 0; i < n; i++){
    for(int k = K; k>=0; k--){
      int val = dp[k];
      int up = a[i];
      int l = 1 + k;
      int r = min(up, K-k) + k;
      if(l <=r){
        pre[l] = (pre[l] + val)%M;
        if(r+1 <=k)
          pre[r+1] = (pre[r+1] - val)%M;
      }
      // for(int i = l; i <=r; i++){
      //   dp[i] += val;
      // }

      // if(l<=r){
      //   pre[l] = (pre[l] + val)%M;
      //   pre[r+1] = (pre[r+1] - val)%M;
      // }
    }
    
    int acc = 0;
    for(int i = 0; i <= K; i++){
      acc = ((acc + pre[i])%M + M)%M;
      dp[i] = ((dp[i] + acc)%M+M)%M;
      pre[i] = 0;
    }
  }

  cout<<(dp[K])%M;
}