#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;
int main(){
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  vector<int> dp(k+2,0);
  dp[0] = 1;
  rep(i,n) {
    vector<int> cum(k+2,0);
    rep(j,k+1) (cum[j+1] =  cum[j] + dp[j]) %= mod;
    rep(j,k+1) (dp[j] = (cum[j+1] - cum[max(0,j-a[i])]) + mod ) %= mod;
  }
  cout << dp[k] << endl;
  return 0;
} 