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