#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  long long dp[n + 1][k + 1];
  dp[0][0] = 1;
  for (int j = (1); j < (k + 1); ++j) dp[0][j] = 0;
  for (int i = (1); i < (n + 1); ++i) {
    dp[i][0] = 1;
    for (int j = (1); j < (k + 1); ++j) {
      dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
      if (j > a[i - 1]) dp[i][j] -= dp[i - 1][j - a[i - 1] - 1];
      while (dp[i][j] < 0) dp[i][j] += mod;
      dp[i][j] %= mod;
    }
  }
  for (int i = 0; i < (n + 1); ++i)
    for (int j = 0; j < (k + 1); ++j) {
      printf("dp(%d, %d) =", i, j);
      cout << dp[i][j] << endl;
    }
  cout << dp[n][k] << endl;
}
