#include <bits/stdc++.h>
#include "../lib/data_structure/bit.hpp"

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n, K; cin >> n >> K;
  vi a(n);
  for(int i=0;i<n;++i) {
    cin >> a[i];
  }

  BIT<ll> bit(K+1);
  bit.add(K, 1);
  //cout << sz << endl;

  for(int i=0;i<n;++i) {
    //printv(bit.node);
    for(int j=0;j<K;++j) {
      int l = j, r = j + a[i];
      l = max(0, l);
      r = min(K, r);
      ll tmp = bit.sum(r) - bit.sum(l);
      //cout << l << ":" << r << ":" << tmp << endl;
      bit.add(j, tmp % MOD);
    }
  }
  
  //printv(bit.node);

  cout << bit.sum(0) << endl;


}
