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