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