#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793

int main(){
  int N, K; cin >> N >> K;
  int dp[N+1][K+1] = {}; int a[N];
  rep(i, N){
    cin >> a[i];
  }
  dp[0][0] = 1;
  for(int i=1; i<=N; i++){
    int cum[K+1] = {0};
    rep(j, K+1){
      cum[j+1] = (cum[j] + dp[i-1][j]) % mod;
    }
    rep(j, K+1){
      dp[i][j] += (cum[j+1] - cum[max(0, j-a[i-1])]);
      dp[i][j] %= mod;
    }
  }
  cout << dp[N][K] << endl; 
}