#include <bits/stdc++.h>
using namespace std;
long long int MOD = pow(10, 9) + 7;
long long int solve(vector<long long int>& kids, long long int K) {
  long long int n = kids.size();
  vector<vector<long long int>> dp(n + 1, vector<long long int>(K + 1));
  vector<long long int> rs(K + 1, 1);
  vector<long long int> nex_rs(K + 1);
  nex_rs[0] = 1;
  for (int i = 0; i <= n; ++i) {
    dp[i][0] = 1;
  }
  for (int i = 1; i <= n; ++i) {
    for (int can = 1; can <= K; ++can) {
      long long int upto = can - kids[i - 1] - 1;
      dp[i][can] = rs[can];
      if (upto >= 0) dp[i][can] -= rs[upto];
      dp[i][can] %= MOD;
      nex_rs[can] = (nex_rs[can - 1] + dp[i][can]) % MOD;
    }
    rs = nex_rs;
    nex_rs.clear();
    nex_rs[0] = 1;
  }
  return dp[n][K];
}
int main() {
  int N, K;
  cin >> N >> K;
  vector<long long int> kids(N);
  for (int i = 0; i < N; ++i) {
    cin >> kids[i];
  }
  cout << solve(kids, K) << endl;
  return 0;
}
