#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 <= a[0]; ++i) {
    dp[0][i] = 1;
    if (i > 0)
      rv[0][i] = rv[0][i - 1] + 1;
    else
      rv[0][i] = 1;
  }
  long long int z = a[0];
  for (int i = 1; i < n; ++i) {
    long long int up, lw, f = 0;
    for (int j = 0; j <= k; ++j) {
      if (j > z && z > -1)
        up = rv[i - 1][z];
      else
        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 && dp[i][j] > 0) rv[i][j] = (rv[i][j] + rv[i][j - 1]) % m;
      if (rv[i][j] == 0 && f == 0) {
        z = j - 1;
        f = 1;
        break;
      }
    }
  }
  cout << dp[n - 1][k] % m << "\n";
}
