#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int>>;
using que_d = priority_queue<int>;
using pint = pair<int, int>;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int n, k;
vector<vector<ll>> dp;
vector<ll> sum;
void rui(int i) {
  for (int j = 0; j < k + 2; j++) sum.at(j) = 0;
  for (int j = 1; j <= k + 1; j++) {
    sum.at(j) += (sum.at(j - 1) + dp.at(i).at(j - 1)) % 1000000007;
  }
  return;
}
int main() {
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a.at(i);
  dp.resize(n + 1, vector<ll>(k + 1));
  sum.resize(k + 2, 0);
  for (int i = 0; i < k + 1; i++) dp.at(0).at(i) = 0;
  for (int i = 0; i < n + 1; i++) dp.at(i).at(0) = 1;
  for (int i = 1; i <= n; i++) {
    rui(i - 1);
    for (int j = 1; j <= k; j++) {
      int point = max(0, j - a.at(i));
      dp.at(i).at(j) = sum.at(j + 1) - sum.at(point);
    }
  }
  cout << dp.at(n).at(k) << endl;
  return 0;
}
