#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const long long MOD = 1e9 + 7;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> v(n + 1);
  for (int i = 0; i < n; i++) cin >> v[i];
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));
  vector<ll> end(k + 1);
  ll ans = 0;
  dp[0][0] = 1;
  for (int i = 0, m; i < n; i++) {
    ans = 0;
    for (int j = 0; j <= k; j++) {
      if (dp[i][j] > 0) {
        ans = (ans + dp[i][j]) % MOD;
        m = min(j + v[i], k);
        end[m] = dp[i][j];
      }
      dp[i + 1][j] = ans;
      ans = ans - end[j];
      end[j] = 0;
    }
  }
  cout << dp[n][k] << '\n';
  return 0;
}
