#include <bits/stdc++.h>
using namespace std;
int main() {
  const int mod = 1e9 + 7;
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<vector<int> > dp(n, vector<int>(k + 2));
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i <= a[0]; i++) dp[0][i]++;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j <= k; j++) {
      int l = j;
      int r = min(a[i + 1] + l + 1, k + 1);
      dp[i + 1][l] += dp[i][j];
      dp[i + 1][r] -= dp[i][j];
    }
    for (int j = 1; j <= k; j++) {
      dp[i + 1][j] += dp[i + 1][j - 1];
      dp[i + 1][j] %= mod;
    }
  }
  cout << dp[n - 1][k] << "\n";
  return 0;
}
