#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  vector<vector<ll>> dp(N, vector<ll>(K + 1));
  for (ll((i)) = (0); ((i)) < ((N)); ((i))++) cin >> a[i];
  for (ll((i)) = (0); ((i)) < ((min(a[0], K) + 1)); ((i))++) dp[0][i] = 1;
  for (ll(i) = (1); (i) < (N); (i)++) {
    for (ll((j)) = (0); ((j)) < ((K)); ((j))++)
      dp[i - 1][j + 1] = (dp[i - 1][j + 1] + dp[i - 1][j]) % MOD;
    for (ll((j)) = (0); ((j)) < ((K + 1)); ((j))++)
      dp[i][j] =
          (dp[i - 1][j] - (j - a[i] - 1 >= 0 ? dp[i - 1][j - a[i] - 1] : 0)) %
          MOD;
  }
  cout << dp.back().back() << endl;
  return 0;
}
