#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e9 + 7;
const ll mod = 1e9 + 7;
vector<ll> nums;
void add(ll& a, const ll b) {
  a += b;
  if (a >= mod) {
    a -= mod;
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  nums.resize(n);
  for (ll& i : nums) {
    scanf("%lld", &i);
  }
  vector<ll> dp(k + 1, 0);
  dp[k] = 1;
  for (int ind = 0; ind < n - 1; ++ind) {
    vector<ll> new_dp(k + 1, 0);
    vector<ll> pre(k + 1, 0);
    for (int avail = k; avail >= 0; --avail) {
      if (dp[avail] == 0) break;
      pre[avail] += dp[avail];
      if (avail - nums[ind] > 0) pre[avail - nums[ind] - 1] -= dp[avail];
    }
    ll run = 0;
    for (int left = k; left >= 0; --left) {
      run += pre[left];
      add(new_dp[left], run);
    }
    dp = new_dp;
  }
  ll ans = 0;
  for (int i = 0; i <= nums[n - 1]; ++i) {
    add(ans, dp[i]);
  }
  printf("%lld\n", ans % mod);
  return 0;
}
