#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long arr[n + 1];
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  vector<long long> dp(k + 1, 1), next(k + 1, 0);
  for (long long i = 1; i <= n; i++) {
    next[0] = 1;
    for (long long j = 1; j <= k; j++) {
      long long left = max(0ll, j - arr[i]);
      next[j] = (left == 0) ? dp[j] : dp[j] - dp[left - 1];
      next[j] += next[j - 1];
      if (next[j] < 0) next[j] += MOD;
    }
    for (long long j = 0; j <= k; j++) dp[j] = next[j];
  }
  if (k != 0)
    cout << (dp[k] - dp[k - 1] + MOD) % MOD;
  else
    cout << 1;
  return 0;
}
