#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 1e9 + 7;
signed main() {
  lint N, K;
  cin >> N >> K;
  vector<lint> a(N);
  for (lint i = 0; i < N; i++) cin >> a[i];
  vector<vector<lint> > dp(N + 1, vector<lint>(K + 1, 0));
  for (lint i = 0; i <= N; i++) dp[i][0] = 1;
  for (lint i = 0; i < N; i++) {
    for (lint j = 1; j <= K; j++) {
      if (j - 1 - a[i] >= 0) {
        dp[i + 1][j] = dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - a[i]]　+ MOD;
        dp[i + 1][j] %= MOD;
      } else
        dp[i + 1][j] = dp[i + 1][j - 1] + dp[i][j];
      dp[i + 1][j] %= MOD;
    }
  }
  cout << dp[N][K] << endl;
}
