#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 + 1);
  for (int i = 0; i < n; i++) cin >> v[i + 1];

  ll dp[n + 1][k + 1] = {};  // i番目(1-index)までの人に合計j個渡す組み合わせの数のMOD
  dp[0][0] = 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][k] % MOD << endl;
}
