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