#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &e : a) cin >> e;
  const int mod = 1e9 + 7;
  vector<vector<int>> dp(n + 1, vector<int>(k + 1));
  for (int i = 0; i <= k; i++) dp[0][i] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      dp[i][j] =
          (dp[i - 1][j] -
           (j - a[i - 1] - 1 >= 0 ? dp[i - 1][j - a[i - 1] - 1] : 0) + mod) %
          mod;
      dp[i][j] = (j ? dp[i][j - 1] + dp[i][j] : dp[i][j]) % mod;
    }
  }
  cout << dp[n][k] - (k ? dp[n][k - 1] : 0);
}
int main() {
  cout << fixed << setprecision(20);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
