#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<vector<long long>> dp(n + 1, vector<long long>(k + 1, 0));
  dp[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    vector<long long> pref(n + 1);
    pref[0] = dp[i - 1][0];
    for (int j = 1; j <= k; j++) {
      pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
    }
    for (int j = 0; j <= k; j++) {
      long long temp = pref[j];
      int lim = j - a[i] - 1;
      if (lim >= 0) {
        temp -= pref[j - a[i] - 1];
      }
      if (temp < 0) temp += mod;
      dp[i][j] = temp;
    }
  }
  cout << dp[n][k];
  return 0;
}
