#include <bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9 + 7;
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> dp(k + 1), v(n);
  for (int64_t i = 0; i < n; ++i) {
    cin >> v[i];
  }
  dp[0] = 1;
  for (int64_t i = 0; i < n; ++i) {
    vector<int64_t> psum(k + 1);
    psum[0] = dp[0];
    for (int64_t j = 1; j <= k; ++j) {
      psum[j] = dp[j];
      psum[j] += psum[j - 1];
      psum[j] %= mod;
    }
    for (int64_t j = 0; j <= k; ++j) {
      int64_t sum = psum[j];
      if (j - v[i] - 1 >= 0) sum -= psum[j - v[i] - 1];
      dp[j] = sum % mod;
    }
  }
  int64_t ans = dp[k];
  cout << ans << '\n';
  return 0;
}
