#include <bits/stdc++.h>
using namespace std;
void FIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  FIO();
  long long n, k;
  cin >> n >> k;
  vector<long long> a(n + 1);
  for (long long i = 1; i < n + 1; i++) cin >> a[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 1));
  for (long long i = 1; i < k + 1; i++) {
    dp[0][i] = 0;
  }
  dp[0][0] = 1;
  for (long long i = 1; i < n + 1; i++) {
    vector<long long> prefix_sum(k + 1);
    prefix_sum[0] = dp[i - 1][0];
    for (long long j = 1; j < k + 1; j++) {
      prefix_sum[j] = (prefix_sum[j - 1] + dp[i - 1][j]) % 1000000007;
    }
    for (long long j = 0; j < k + 1; j++) {
      if (j <= a[i])
        dp[i][j] = prefix_sum[j];
      else {
        long long exclude_index = j - a[i] - 1;
        dp[i][j] = (prefix_sum[j] - prefix_sum[exclude_index]) % 1000000007;
      }
    }
    prefix_sum.clear();
  }
  cout << dp[n][k] << '\n';
  return 0;
}
