#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  ll MOD = 1000000007;
  int n, k;
  cin >> n >> k;
  vi a(n + 1);
  for (int i = 0; i < (int)(n); i++) cin >> a[i + 1];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));
  for (int i = 0; i < (int)(n + 1); i++) dp[i][0] = 1;
  for (int j = 0; j < (int)(k); j++) dp[0][j + 1] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      if (j - 1 - a[i] >= 0)
        dp[i][j] =
            (dp[i - 1][j - 1] - dp[i - 1][j - 1 - a[i]] + dp[i][j - 1] + MOD) %
            MOD;
      else
        dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % MOD;
    }
  }
  ll ans = (dp[n][k] - dp[n][k - 1] + MOD) % MOD;
  if (k >= 1)
    cout << ans << endl;
  else
    cout << 1 << endl;
}
