#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  vector<int64_t> dp(k + 1, 0);
  dp.at(0) = 1;
  vector<int64_t> cumsum_dp(k + 2, 1);
  cumsum_dp.at(0) = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      dp.at(j) = (cumsum_dp.at(j + 1) - cumsum_dp.at(max(0, j - a.at(i)))) %
                 1000000007;
    }
    for (int j = 2; j <= k + 1; j++) {
      cumsum_dp.at(j) = (cumsum_dp.at(j - 1) + dp.at(j - 1)) % 1000000007;
    }
  }
  cout << dp.at(k) << endl;
}
