#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8 + 7;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  vector<int> as(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &as[i]);
  }
  vector<ll> dp(k + 1, 0);
  ll run = 0;
  for (int i = as[n - 1]; i >= 0; --i) {
    run++;
    dp[i] = run;
  }
  for (int i = n - 2; i >= 0; --i) {
    vector<ll> new_dp(k + 1, 0);
    run = 0;
    for (int left = k; left >= 0; --left) {
      run += dp[max(0, left - as[i])] - (left + 1 <= k ? dp[left + 1] : 0);
      new_dp[left] = run;
    }
    if (new_dp[k] >= mod) {
      for (int j = 0; j <= k; ++j) {
        new_dp[j] %= mod;
      }
    }
    dp = new_dp;
  }
  if (n == 1 && as[0] == k)
    run = 1;
  else if (n == 1)
    run = 0;
  cout << dp[k] % mod << endl;
  return 0;
}
