#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
int solve() {
  int n, K, x;
  cin >> n >> K;
  vector<int> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  long long dp[n][K + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= min(A[0], K); i++) dp[0][i] = 1;
  for (int i = 1; i < n; i++) {
    x = min(A[i], K);
    dp[i][0] = 1;
    long long sum = dp[i - 1][0];
    for (int k = 1; k <= x; k++) {
      sum = (sum + dp[i - 1][k]) % M;
      dp[i][k] = sum;
    }
    for (int k = x + 1; k <= K; k++) {
      sum = (sum - dp[i - 1][k - x - 1] + M) % M;
      dp[i][k] = sum;
    }
  }
  return dp[n - 1][K];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << solve() << "\n";
}
