#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int mod = 1e9 + 7;
int dp[2][100010];
int p[100010];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  dp[1][0] = 1;
  int r = 0;
  memset(p, 0, sizeof(p));
  for (int i = 0; i < n; i++) {
    p[0] = 0;
    for (int j = 1; j <= k + 1; j++) p[j] = (dp[1 - r][j - 1] + p[j - 1]) % mod;
    for (int j = 1; j <= k; j++) dp[r][j] = p[j + 1] - p[max(0, j - a[i])];
    r ^= 1;
  }
  cout << dp[1 - r][k];
  return 0;
}
