#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n + 1];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n; i++) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= k; i++) {
    if (a[0] >= i)
      dp[0][i] = (dp[0][i - 1] + 1) % mod;
    else
      dp[0][i] = dp[0][i - 1];
  }
  if (n == 1) {
    cout << dp[0][k] - dp[0][k - 1];
    return 0;
  }
  for (int cand = 1; cand <= k; cand++) {
    for (int i = 1; i < n - 1; i++) {
      int temp = 0;
      if (cand > a[i])
        temp = (dp[i - 1][cand] % mod - dp[i - 1][cand - a[i] - 1] % mod) % mod;
      else
        temp = dp[i - 1][cand] % mod;
      dp[i][cand] = (dp[i][cand - 1] % mod + temp % mod) % mod;
    }
  }
  if (k > a[n - 1])
    cout << dp[n - 2][k] - dp[n - 2][k - a[n - 1] - 1];
  else
    cout << dp[n - 2][k];
  return 0;
}
