#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int a[n];
  for (auto i = 0; i < n; i++) cin >> a[i];
  long long int dp[k + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  for (auto i = 0; i < k + 1; i++) {
    if (i <= a[0])
      dp[i][1] = 1;
    else
      dp[i][1] = 0;
    if (i == 0)
      dp[i][0] = dp[i][1];
    else
      dp[i][0] = (dp[i - 1][0] + dp[i][1]) % 1000000007;
  }
  for (long long int N = 2; N <= n; N++) {
    for (long long int K = 0; K <= k; K++) {
      if (a[N - 1] < K) {
        cerr << "LINE: " << 51 << " || "
             << "K"
             << " = " << K << "\n";
        dp[K][N] =
            (dp[K][0] - dp[K - a[N - 1] - 1][0] + 1000000007) % 1000000007;
      } else
        dp[K][N] = dp[K][0] % 1000000007;
    }
    for (long long int K = 0; K <= k; K++) {
      if (K == 0)
        dp[K][0] = dp[K][N] % 1000000007;
      else
        dp[K][0] = (dp[K - 1][0] + dp[K][N]) % 1000000007;
    }
  }
  cout << dp[k][n] % 1000000007 << "\n";
  return 0;
}
