#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 6;
const int M = 1e9 + 7;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
int A[N];
int n, a, b;
int dp[2][N];
void solve() {
  cout << INT_MAX << "\n";
  cin >> n >> a;
  for (int i = 1; i < n + 1; i++) cin >> A[i];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  for (int i = 1; i < n + 1; i++) {
    for (int j = 0; j < a + 1; j++) {
      int ans = 0;
      ans = dp[(i - 1) % 2][j];
      if (j - 1 >= 0) ans += dp[i % 2][j - 1], ans % M;
      if (j - 1 >= A[i]) ans -= dp[(i - 1) % 2][j - 1 - A[i]];
      if (ans < 0) ans += M;
      dp[i % 2][j] = ans % M;
    }
  }
  cout << dp[n % 2][a];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) solve();
}
