#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vpl = vector<pll>;
using vvpl = vector<vpl>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ld = long double;
using vd = vector<ld>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-9;
const ll mod = 1e9 + 7;
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, K;
  cin >> N >> K;
  {
    if (0) cerr << ("N") << " = " << (N) << "\n";
  };
  {
    if (0) cerr << ("K") << " = " << (K) << "\n";
  };
  vvl dp(N + 2, vl(K + 2, 0));
  ll bisher = 0;
  for (ll i = (1); i < (N + 1); (i)++) {
    ll ai;
    cin >> ai;
    bisher += ai;
    dp[i][0] = 1;
    for (ll j = (1); j < (K + 1); (j)++) {
      if (j <= ai) {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod;
      } else if (j <= bisher) {
        dp[i][j] = (dp[i - 1][j] + dp[i][j - 1] - dp[i][j - ai - 1]) % mod;
      }
      {
        if (0)
          cerr << ("dp") << "[" << i << "][" << j << "] = " << (dp[i][j])
               << "\n";
      };
    }
  }
  cout << dp[N][K] << endl;
}
