#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int64_t mod = 1e9 + 7;
int64_t mod1 = 1e9 + 5;
int64_t power(int64_t a, int64_t b) {
  if (b == 0)
    return 1;
  else if (b % 2 == 0)
    return power((((a % mod) * (a % mod)) % mod), b / 2) % mod;
  else
    return ((a % mod) * (power((((a % mod) * (a % mod)) % mod), b / 2) % mod)) %
           mod;
}
int64_t dp[100001][101];
int64_t cum[100001][101];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int64_t n, k;
  cin >> n >> k;
  int64_t a[n];
  for (int64_t i = 0; i < n; ++i) cin >> a[i];
  if (k == 0) {
    cout << 1;
    return 0;
  }
  memset(dp, 0, sizeof(dp));
  memset(cum, 0, sizeof(cum));
  for (int64_t i = 0; i <= n; ++i) dp[0][i] = 1, cum[0][i] = 1;
  for (int64_t i = 1; i <= n; ++i) {
    dp[1][i] = dp[1][i - 1];
    if (a[i - 1] > 0) dp[1][i]++;
    cum[1][i] = cum[0][i] + dp[1][i];
  }
  for (int64_t i = 1; i <= k; ++i) {
    cum[i][1] = cum[i - 1][1];
    if (i <= a[0]) {
      cum[i][1]++;
    }
  }
  for (int64_t i = 2; i <= k; ++i) {
    for (int64_t j = 2; j <= n; ++j) {
      dp[i][j] = cum[i][j - 1];
      if (min(i, a[j - 1]) != i and i - min(i, a[j - 1]) != 0) {
        dp[i][j] -= cum[i - min(i, a[j - 1]) - 1][j - 1];
        dp[i][j] += mod;
        dp[i][j] %= mod;
      }
      cum[i][j] += cum[i - 1][j] + dp[i][j];
      cum[i][j] %= mod;
    }
  }
  cout << dp[k][n];
}
