#include <bits/stdc++.h>
using namespace std;
int mod = pow(10, 9) + 7;
int main() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> x(n);
  for (long long int i = 0; i < n; i++) cin >> x[i];
  vector<long long int> ab(k + 1, 0);
  vector<vector<long long int> > dp(n + 1, ab);
  for (long long int i = 1; i <= n; i++) {
    dp[i][0] = 1;
  }
  for (long long int j = 0; j <= k; j++) {
    if (x[0] >= j) dp[1][j] = 1;
  }
  dp[0][0] = 0;
  for (long long int i = 2; i <= n; i++) {
    for (long long int j = 1; j <= k; j++) {
      dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
      if (x[i - 1] < j) dp[i][j] -= dp[i - 1][j - x[i - 1] - 1];
    }
  }
  cout << dp[n][k] % mod;
  return 0;
}
