#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000000 + 7;
const long double EPS = 0.0000001;
long long pows(long long a, long long b) {
  if (b == 0) return 1LL;
  long long temp = pows(a, b / 2);
  temp = (temp * temp) % MOD;
  if (b % 2) temp = (temp * a) % MOD;
  return temp;
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long dp[n][k + 1];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= k; j++) dp[i][j] = 0;
  }
  if (k == 0) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i <= min(arr[0], k); i++) dp[0][i] = 1;
  for (int i = 1; i <= k; i++) dp[0][i] += dp[0][i - 1];
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j <= k; j++) {
      int mn = max(0LL, j - arr[i]);
      dp[i][j] = dp[i - 1][j];
      if (mn != 0) {
        dp[i][j] = (dp[i][j] - dp[i - 1][mn - 1] + MOD) % MOD;
      }
    }
    for (int j = 1; j <= k; j++) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
  }
  long long ans = (dp[n - 1][k] + MOD - dp[n - 1][k - 1]) % MOD;
  cout << ans << endl;
  return 0;
}
