#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < (N); i++) cin >> a[i];
  vector<vector<long long>> dp(N + 1, vector<long long>(K + 10));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      dp.at(i).at(j) += dp.at(i - 1).at(j);
      if (j + a.at(i - 1) + 1 > K + 5) continue;
      dp.at(i).at(j + a.at(i - 1) + 1) -= dp.at(i - 1).at(j);
    }
    for (int j = 1; j <= K + 5; j++) {
      dp[i][j] = (dp[i][j] + dp[i][j - 1]);
    }
  }
  cout << dp[N][K] % 1000000007 << endl;
  return 0;
}
