#include <bits/stdc++.h>
using namespace std;
void add_self(long long int& a, long long int b) {
  a += b;
  if (a >= 1000000007) {
    a -= 1000000007;
  }
  if (a < 0) {
    a += 1000000007;
  }
}
int32_t main() {
  std::ios::sync_with_stdio(false);
  long long int n, k;
  cin >> n >> k;
  vector<long long int> dp(k + 1);
  dp[0] = 1;
  for (long long int i = 0; i < n; i++) {
    long long int upto;
    cin >> upto;
    vector<long long int> fake(k + 1);
    for (long long int used = k; used >= 0; --used) {
      long long int L = used + 1;
      long long int R = used + min(upto, k - used) + 1;
      if (L <= R) add_self(fake[L], dp[used]);
      if (R <= k) add_self(fake[R], -dp[used]);
    }
    long long int prefix = 0;
    for (long long int i = 0; i <= k; ++i) {
      add_self(prefix, fake[i]);
      add_self(dp[i], prefix);
    }
  }
  cout << dp[k] % 1000000007 << endl;
  return 0;
}
