#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vpi = vector<pi>;
using vvpi = vector<vpi>;
const ull MOD = (int)1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  vi psa(n);
  psa[0] = a[0];
  for (int i = 1; i < n; ++i) psa[i] = psa[i - 1] + a[i];
  vi dp(k + 1, 0);
  vi ps(k + 1, 0);
  for (int j = 0; j <= a[0]; ++j) dp[j] = 1;
  ps[0] = dp[0];
  for (int j = 1; j <= k; ++j) ps[j] = (ps[j - 1] + dp[j]) % MOD;
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= min(k, psa[i]); ++j) {
      dp[j] = ps[j];
      if (j - a[i] - 1 >= 0) dp[j] -= ps[j - a[i] - 1];
    }
    ps[0] = dp[0];
    for (int j = 1; j <= k; ++j) ps[j] = (ps[j - 1] + dp[j]) % MOD;
  }
  cout << dp[k] << '\n';
}
