#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  vector<long long> dp(k + 1, 1);
  for (int i = 1; i <= n; i++) {
    vector<long long> new_dp(k + 1);
    for (int j = 0; j <= k; j++) {
      int l = max(0, j - a[i]);
      if (l == 0) {
        new_dp[j] += dp[j];
        new_dp[j] %= mod;
      } else {
        new_dp[j] += (dp[j] - dp[l - 1] + mod) % mod;
        new_dp[j] %= mod;
      }
    }
    for (int j = 0; j <= k; j++) {
      dp[j] = new_dp[j];
      if (j > 0) {
        dp[j] += dp[j - 1];
        dp[j] %= mod;
      }
    }
  }
  cout << ((k == 0) ? 1 : (dp[k] - dp[k - 1])) << endl;
}
int main() {
  solve();
  return 0;
}
