#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
using namespace std;
const long long MOD = 1e+9 + 7;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int INFi = 0x3f3f3f3f;
const long long MAXN = 1e+6 + 7;
void mod_sum(long long& a, long long b) {
  a += b;
  if (a >= MOD)
    a -= MOD;
  else if (a < 0)
    a += MOD;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ;
  long long i, j, n, k;
  cin >> n >> k;
  vector<long long> A(n), K(k + 1);
  vector<vector<long long> > dp(n, vector<long long>(k + 1));
  for (auto& a : A) {
    cin >> a;
    ++K[a];
  }
  for (i = 0; i <= A[0]; ++i) dp[0][i] = 1;
  for (i = 1; i < n; ++i) {
    vector<long long> sums(k + 2);
    for (j = 0; dp[i - 1][j]; ++j) {
      mod_sum(sums[j], dp[i - 1][j]);
      mod_sum(sums[min(j + A[i] + 1, (long long)(int)(dp[i]).size())],
              -dp[i - 1][j]);
    }
    mod_sum(dp[i][0], sums[0]);
    for (j = 1; j < (int)(dp[i]).size(); ++j) {
      mod_sum(sums[j], sums[j - 1]);
      mod_sum(dp[i][j], sums[j]);
    }
  }
  if (0)
    for (i = 0; i < (int)(dp).size(); ++i) {
      for (j = 0; j < min(30, (int)(dp[i]).size()); ++j)
        printf("% 3lld", dp[i][j]);
      printf("\n");
    }
  cout << dp[n - 1][k] << '\n';
  return 0;
}
