#include <bits/stdc++.h>
using namespace std;
int main() {
  long long mod = 1000000007;
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  long long arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<long long> dp;
  vector<long long> dp2;
  dp.push_back(1);
  for (int i = 0; i < n; i++) {
    for (int j = 1; j < dp.size(); j++) {
      dp[j] += dp[j - 1];
      dp[j] %= mod;
    }
    for (long long j = 0; j < dp.size() + arr[i]; j++) {
      int l = max(0ll, j - arr[i]);
      int r = min((long long)dp.size() - 1, j);
      long long ans = dp[r];
      if (l != 0) ans -= dp[l - 1];
      ans += mod;
      ans += mod;
      ans %= mod;
      dp2.push_back(ans);
    }
    swap(dp, dp2);
    dp2.clear();
  }
  if (k >= dp.size())
    cout << 0;
  else
    cout << dp[k];
  return 0;
}
