#include <bits/stdc++.h>
using namespace std;
long long int mod = 1e9 + 7;
void pre() {}
void solve() {
  long long int n, k;
  cin >> n >> k;
  long long int arr[n];
  long long int dp[n + 1][k + 1];
  for (long long int i = 0; i <= n; i++)
    for (long long int j = 0; j <= k; j++) dp[i][j] = 0;
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  for (long long int i = 0; i <= k; i++) dp[0][i] = 0;
  dp[0][0] = 1;
  for (long long int i = 1; i <= n; i++) {
    long long int a = 0;
    long long int iter = 0;
    for (long long int j = 0; j <= k; j++) {
      a += dp[i - 1][j];
      a %= mod;
      iter++;
      if (iter > arr[i - 1] + 1) {
        a = (a - dp[i - 1][j - arr[i - 1] - 1]) % mod;
        iter--;
      }
      dp[i][j] = a % mod;
    }
  }
  cout << dp[n][k] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  pre();
  long long int num = 1;
  for (long long int i = 0; i < num; i++) {
    solve();
  }
}
