#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int MOD = 1000000007;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < (N); ++i) cin >> a[i];
  vector<vector<int>> dp(N + 1, vector<int>(K + 1, 0));
  vector<vector<int>> dp_sum(N + 1, vector<int>(K + 1, 0));
  dp[0][0] = 1;
  for (int j = 0; j < (K + 1); ++j) dp_sum[0][j] = 1;
  for (int i = 0; i < (N + 1); ++i) dp_sum[i][0] = 1;
  for (int i = 0; i < (N); ++i)
    for (int j = 0; j < (K + 1); ++j) {
      if (a[i] >= j) {
        dp[i + 1][j] = dp_sum[i][j];
        if (j) dp_sum[i + 1][j] = (dp_sum[i + 1][j - 1] + dp[i + 1][j]) % MOD;
      } else {
        dp[i + 1][j] = dp_sum[i][j] - dp_sum[i][j - a[i] - 1];
        dp_sum[i + 1][j] = (dp_sum[i + 1][j - 1] + dp[i + 1][j]) % MOD;
      }
    }
  cout << dp[N][K] << endl;
  return 0;
}
