#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int INF = INT_MAX;
const int sze = 3005;
void solve() {
  int n, k;
  cin >> n >> k;
  long long int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  long long int dp[n + 1][k + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i < n + 1; i++) dp[i][0] = 1;
  for (int i = 1; i <= n; i++) {
    long long int pre[n + 1];
    pre[0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) pre[j] = (pre[j - 1] + dp[i - 1][j]) % mod;
    for (int j = 1; j <= k; j++) {
      if (arr[i - 1] < j) {
        dp[i][j] = (pre[j] - pre[j - arr[i - 1] - 1]) % mod;
      } else
        dp[i][j] = pre[j] % mod;
    }
  }
  cout << dp[n][k] << endl;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
