#include <bits/stdc++.h>
using namespace std;
int p = 1e9 + 7;
int main() {
  int n, k;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  int dp[k + 1][n + 1], cum_sum_dp[k + 1][n + 1];
  memset(dp, 0, sizeof(dp));
  memset(cum_sum_dp, 0, sizeof(dp));
  for (int i = 0; i <= k; i++) {
    dp[i][0] = 0;
  }
  for (int i = 0; i <= n; i++) dp[0][i] = 1;
  for (int K = 1; K <= k; K++) {
    for (int j = 1; j <= n; j++) {
      if (arr[j - 1] >= K) {
        dp[K][j] = (dp[K - 1][j] % p + dp[K][j - 1] % p + p) % p;
      } else {
        dp[K][j] = (cum_sum_dp[K][j - 1] % p -
                    cum_sum_dp[K - arr[j - 1] - 1][j - 1] % p + p) %
                   p;
      }
      cum_sum_dp[K][j] = (dp[K][j] % p + cum_sum_dp[K - 1][j] % p + p) % p;
    }
  }
  cout << dp[k][n] << endl;
}
