#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int main(void) {
  int N;
  long long K;
  cin >> N >> K;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  vector<long long> dp[N];
  for (int i = 0; i < N; i++) dp[i].resize(K + 1);
  for (int i = 0; i < K + 1; i++) {
    if (i <= A[0])
      dp[0][i] = 1;
    else
      dp[0][i] = 0;
  }
  for (int i = 0; i < N; i++) dp[i][0] = 1;
  for (int i = 1; i < N; i++) {
    for (int j = 1; j <= K; j++) {
      dp[i][j] = dp[i][j - 1] + dp[i - 1][j];
      if (j - A[i] - 1 >= 0) dp[i][j] -= dp[i - 1][j - A[i] - 1];
      dp[i][j] %= mod;
    }
  }
  cout << dp[N - 1][K] << endl;
  return 0;
}
