#include <bits/stdc++.h>
using namespace std;
void add(long long &a, long long b) {
  a = ((a + b) % 1000000007 + 1000000007) % 1000000007;
}
inline long long mul(long long a, long long b) {
  return (long long)((long long)a * b % 1000000007);
  unsigned long long x = (long long)a * b;
  unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
  asm("divl %4; \n\t" : "=a"(d), "=d"(m) : "d"(xh), "a"(xl), "r"(1000000007));
  return m;
}
inline long long modpow(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
inline long long inv(long long a) {
  a %= 1000000007;
  if (a < 0) a += 1000000007;
  long long b = 1000000007, u = 0, v = 1;
  while (a) {
    long long t = b / a;
    b -= t * a;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += 1000000007;
  return u;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n);
  for (long long i = (0); i < (n); i++) cin >> a[i];
  vector<long long> dp[n + 1];
  for (long long i = (0); i < (n + 1); i++) dp[i].assign(k + 1, 0);
  dp[0][0] = 1;
  for (long long i = (0); i < (n); i++) {
    for (long long j = (0); j < (k + 1); j++) {
      add(dp[i + 1][j], dp[i][j]);
      if (j + a[i] < n) add(dp[i + 1][j + a[i] + 1], -dp[i][j]);
    }
    for (long long j = (0); j < (k); j++) add(dp[i + 1][j + 1], dp[i + 1][j]);
  }
  cout << dp[n][k] << endl;
  return 0;
}
