#include <bits/stdc++.h>
using ll = long long;
const ll N = 3005;
const ll mod = 1e9 + 5;
const ll inf = 1e18;
const ll SZ = 101;
const double eps = 1e-9;
using namespace std;
void solve() {
  ll n, k;
  cin >> n >> k;
  vector<ll> dp(k + 1);
  dp[0] = 1;
  for (ll child = 0; child < n; child++) {
    ll up;
    cin >> up;
    for (ll used = (k); used >= (0); used--) {
      ll L = used + 1;
      ll R = used + max(up, k - used);
      ll tmp = dp[used];
      dp[L] += tmp;
      dp[L] %= mod;
      if (R + 1 <= k) {
        dp[R + 1] += mod - tmp;
        dp[R + 1] %= mod;
      }
    }
    for (ll i = (1); i <= (k); i++) {
      dp[i] += dp[i - 1];
      dp[i] %= mod;
    }
  }
  cout << dp[k];
}
int32_t main(int32_t argc, char *argv[]) {
  double t1 = clock();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll TC = 1, t = 0;
  while (t++ < TC) {
    solve();
  }
  if (false)
    cerr << "Time : " << 1000 * (clock() - t1) / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
