#include <bits/stdc++.h>
using namespace std;
const int MOD = pow(10,9)+7;
int main(){
  int N,K,a;
  cin >> N >> K;
  vector<int> cnt(K+1);
  cnt[0] = 1;
  for(int i = 0; i < N; ++i){
    cin >> a;
    int psum = 0;
    for(int k = K-1; k >= max(0,K-a); --k) psum = (psum+cnt[k])%MOD;
    cnt[K] = (cnt[K]+psum)%MOD;
    for(int j = K-1; j > 0; --j){
      psum = (psum-cnt[j])%MOD;
      if(j-a >= 0) psum = (psum+cnt[j-a])%MOD;
      cnt[j] = (cnt[j]+psum)%MOD;
    }
  }
  cout << (cnt[K]+MOD)%MOD;
  return 0;
}