#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 1e9 + 7;
const int64_t N = 1e6 + 5;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int64_t n, k;
  cin >> n >> k;
  int64_t arr[n];
  for (int64_t i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int64_t dp[k + 1];
  int64_t ndp[k + 1];
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (int64_t i = 0; i < n; i++) {
    ndp[0] = dp[0];
    for (int64_t i = 1; i <= k; i++) {
      ndp[i] = dp[i] - dp[i - 1];
    }
    for (int64_t j = 0; j < k; j++) {
      int64_t ll = j + 1;
      int64_t rr = min(k, j + arr[i]);
      ndp[ll] += dp[j];
      if (rr + 1 <= k) ndp[rr + 1] -= dp[j];
    }
    dp[0] = ndp[0];
    for (int64_t i = 1; i <= k; i++) {
      dp[i] = (dp[i - 1] + ndp[i]) % MOD;
    }
  }
  cout << dp[k];
  return 0;
}
