#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
ll MOD = 1000000007;

// ====================================================================

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];

  ll dp[n + 1][k + 1] = {};                              // i番目までの人に合計j個渡す組み合わせの数のMOD
  for (int j = 0; j <= min(v[0], k); j++) dp[0][j] = 1;  // 1列目を埋める

  for (int i = 1; i < n; i++) {
    ll rui[k + 2] = {};  // 一つ前の累積をとっておく
    for (int j = 0; j <= k + 1; j++)
      rui[j + 1] = (rui[j] + dp[i - 1][j]) % MOD;
    for (int j = 0; j <= k; j++)
      dp[i][j] = (rui[j + 1] - rui[max(0ll, j - v[i])]) % MOD;
  }

  cout << dp[n - 1][k] << endl;
}
