#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long dp[n + 2][k + 20];
  memset(dp, 0, sizeof dp);
  dp[0][0] = 1;
  dp[0][arr[0] + 1] = -1;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j <= k + 10; j++) {
      if (j) dp[i - 1][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % 1000000007;
      if (dp[i - 1][j] == 0) break;
      dp[i][j] = (dp[i][j] + dp[i - 1][j]) % 1000000007;
      if ((j + arr[i] + 1) <= (k + 10))
        dp[i][j + arr[i] + 1] =
            (dp[i][j + arr[i] + 1] - dp[i - 1][j] + 1000000007) % 1000000007;
    }
  }
  for (long long i = 1; i <= k + 10; i++)
    dp[n - 1][i] = (dp[n - 1][i] + dp[n - 1][i - 1]) % 1000000007;
  cout << dp[n - 1][k] << "\n";
}
