#include <bits/stdc++.h>
using namespace std;
int main() {
  const int MOD = 1e9 + 7;
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for (int& i : v) cin >> i;
  vector<vector<int> > dp(n + 1, vector<int>(k + 1));
  dp[0][0] = 1;
  vector<int> p(k + 2, 1);
  p[0] = 0;
  vector<int> nxt(k + 2);
  for (int i = 1; i < (n + 1); ++i) {
    nxt.assign(k + 2, 0);
    for (int j = 0; j < (k + 1); ++j) {
      dp[i][j] = (p[j + 1] - p[j - min(j, v[i - 1])]) % MOD;
      nxt[j + 1] = (nxt[j] + dp[i][j]) % MOD;
    }
    swap(p, nxt);
  }
  cout << dp[n][k];
}
