#include <bits/stdc++.h>
using namespace std;
int MOD = 1e9 + 7;
long long int mymod(long long int A) {
  A %= MOD;
  if (A < 0) A += MOD;
  return A;
}
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = (0); i < (n); i++) cin >> a[i];
  long long int dp[n][k + 1];
  dp[0][0] = 1;
  for (int i = (1); i < (k + 1); i++) {
    if (i <= a[0])
      dp[0][i] = dp[0][i - 1] + 1;
    else
      dp[0][i] = dp[0][i - 1];
  }
  for (int i = (1); i < (n); i++) {
    for (int j = (0); j < (k + 1); j++) {
      if (j - a[i] - 1 < 0)
        dp[i][j] = dp[i - 1][j];
      else
        dp[i][j] = mymod(dp[i - 1][j] - dp[i - 1][j - a[i] - 1]);
      if (j > 0) dp[i][j] = mymod(dp[i][j - 1] + dp[i][j]);
    }
  }
  cout << mymod(dp[n - 1][k] - dp[n - 1][k - 1]) << endl;
}
