#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, m = 1000000007;
  cin >> n >> k;
  std::vector<long long int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  std::vector<std::vector<long long int> > dp(
      n, std::vector<long long int>(k + 1, 0));
  std::vector<std::vector<long long int> > rv(
      n, std::vector<long long int>(k + 1, 0));
  for (int i = 0; i <= k; ++i) {
    if (i <= a[0]) {
      dp[0][i] = 1;
      if (i > 0)
        rv[0][i] = rv[0][i - 1] + 1;
      else
        rv[0][i] = 1;
    } else
      rv[0][i] = a[0] + 1;
  }
  for (int i = 1; i < n; ++i) {
    long long int up, lw, f = 0;
    for (int j = 0; j <= k; ++j) {
      up = rv[i - 1][j];
      if (j > a[i])
        lw = rv[i - 1][j - a[i] - 1];
      else
        lw = 0;
      if ((up - lw) > 0) dp[i][j] = (up - lw) % m;
      rv[i][j] = dp[i][j];
      if (j > 0) rv[i][j] = (rv[i][j] + rv[i][j - 1]) % m;
    }
  }
  cout << dp[n - 1][k] % m << "\n";
}
