#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void solve() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long ar[n];
  for (long long i = 0; i < n; i++) cin >> ar[i];
  vector<long long> dp(k + 1);
  dp[0] = 1;
  for (long long i = 0; i < n; i++) {
    vector<long long> temp(k + 1);
    for (long long j = k; j >= 0; j--) {
      long long l = j + 1;
      long long r = j + min(ar[i], k - j);
      if (l <= r) {
        temp[l] += dp[j];
        if (r + 1 <= k) {
          temp[r + 1] -= dp[j];
        }
      }
    }
    for (long long i = 1; i < k + 1; i++) {
      temp[i] += temp[i - 1];
      temp[i] %= mod;
    }
    for (long long i = 0; i < k + 1; i++) {
      dp[i] += temp[i];
      dp[i] %= mod;
    }
  }
  cout << dp[k] % mod << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  for (long long i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
