#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  int dp[n + 1][k + 1];
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < k + 1; j++) dp[i][j] = 0;
  dp[0][0] = 1;
  int mod = 1e9 + 7;
  int lim = 0;
  for (int i = 1; i <= (int)(n); i++) {
    int sum = dp[i - 1][0];
    lim += a[i - 1];
    for (int j = 0; j < k + 1; j++) {
      if (lim < j) break;
      if (a[i - 1] < j) sum -= dp[i - 1][j - a[i - 1] - 1];
      dp[i][j] = sum;
      if (j != k) sum += dp[i - 1][j + 1];
      sum %= mod;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
