#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, k, mod = 1000000007;
  cin >> n >> k;
  vector<int64_t> as(n);
  for (auto &a : as) {
    cin >> a;
  }
  vector<vector<int64_t>> dp(n + 1, vector<int64_t>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    vector<int64_t> add(k + 1, 0);
    for (int j = 0; j <= k; j++) {
      (add[j] += dp[i][j]) %= mod;
      if (j + as[i] + 1 <= k) {
        add[j + as[i] + 1] += -dp[i][j];
      }
    }
    for (int j = 1; j <= k; j++) {
      (add[j] += add[j - 1]) %= mod;
    }
    dp[i + 1] = add;
  }
  cout << dp[n][k] << endl;
  return 0;
}
