#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<long long> vec(n);
  for (int i = 0; i < n; i++) cin >> vec[i];
  vector<vector<long long> > dp(n + 1, vector<long long>(k + 1));
  vector<long long> pref(k + 1);
  pref[0] = 1;
  for (int i = 1; i < k + 1; i++) {
    pref[i] += pref[i - 1];
  }
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int used = 0; used <= k; used++) {
      if (used - vec[i - 1] > 0)
        dp[i][used] = (pref[used] - pref[used - vec[i - 1] - 1]);
      else
        dp[i][used] = (pref[used]);
      dp[i][used] %= mod;
    }
    for (int j = 0; j <= k; j++) pref[j] = 0;
    for (int j = 0; j <= k; j++) {
      if (j - 1 >= 0)
        pref[j] += pref[j - 1] + dp[i][j];
      else
        pref[j] = dp[i][j];
      pref[j] %= mod;
    }
  }
  cout << dp[n][k];
}
