#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long dp2[n + 1];
  dp2[n] = 0;
  for (long long i = n - 1; i >= 1; i--) dp2[i] = dp2[i + 1] + a[i];
  long long dp[n + 1][k + 1];
  for (long long i = 0; i < k + 1; i++) dp[0][i] = 0;
  for (long long i = 0; i < n + 1; i++) dp[i][0] = 1;
  for (long long i = 0; i < n + 1; i++) {
    if (i == 0) continue;
    long long prev = 0;
    long long c = 0;
    for (long long j = max(0ll, k - dp2[i] - a[i - 1]); j < k + 1; j++) {
      c++;
      prev += dp[i - 1][j];
      prev = prev % 1000000007;
      if (c >= a[i - 1] + 2) {
        prev -= dp[i - 1][j - a[i - 1] - 1] % 1000000007;
        prev = prev % 1000000007;
      }
      if (j >= k - dp2[i]) {
        dp[i][j] = prev;
      }
    }
  }
  cout << dp[n][k];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test;
  test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
