#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long int N = 2e5 + 5;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  long long int v[n];
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  long long int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  long long int prefix[n + 1][k + 1];
  memset(prefix, 0, sizeof(prefix));
  for (long long int i = 0; i <= k; i++) {
    prefix[n][i] = 1;
  }
  for (long long int i = n - 1; i >= 0; i--) {
    for (long long int j = 0; j <= k; j++) {
      long long int l = max(j - v[i], (long long)0);
      long long int r = j;
      if (l == 0) {
        dp[i][j] = prefix[i + 1][r] % mod;
      } else if (l > 0) {
        dp[i][j] = (prefix[i + 1][r] % mod - prefix[i + 1][l - 1] % mod) % mod;
      }
      prefix[i][j] = dp[i][j];
      if (j != 0) {
        prefix[i][j] = (prefix[i][j] % mod + prefix[i][j - 1] % mod) % mod;
      }
      prefix[i][j] = prefix[i][j] % mod;
    }
  }
  cout << dp[0][k] % mod << endl;
}
