#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 + 1));
  dp[0][0] = 1;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j <= K; j++) {
      if (dp.at(i - 1).at(j) == 0) break;
      dp.at(i).at(j) = dp.at(i).at(j) + dp.at(i - 1).at(j);
      if (j + a[i - 1] + 1 > K) continue;
      dp.at(i).at(j + a[i - 1] + 1) -= dp.at(i - 1).at(j);
    }
    for (int j = 1; j <= K; j++) {
      dp[i][j] = (dp[i][j] + dp[i][j - 1]) % 1000000007;
    }
  }
  cout << dp[N][K] << endl;
  return 0;
}
