#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
int n, k;
vector<int> arr;
vector<vector<int>> dp;
int main() {
  cin >> n >> k;
  arr.resize(n);
  dp.resize(n + 1, vector<int>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    vector<int> ps(k + 1, 0);
    int cur = 0;
    for (int u = 0; u <= k; u++) {
      cur = (cur % mod + dp[i - 1][u] % mod);
      ps[u] = cur % mod;
    }
    for (int j = 0; j <= k; j++) {
      int idx = j - arr[i - 1] - 1;
      if (idx < 0) {
        dp[i][j] = ps[j] % mod;
      } else {
        dp[i][j] = (ps[j] - ps[idx]) % mod;
      }
    }
  }
  int res = dp[n][k];
  cout << res << endl;
  return 0;
}
