#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int mod(int x) { return x < 0 ? x + MOD : x % MOD; }
int main() {
  int N, K;
  cin >> N >> K;
  if (!K) {
    cout << 1 << endl;
    return 0;
  }
  int dp[N][K + 1], arr[N];
  for (int i = 0; i < N; i++) cin >> arr[i];
  dp[0][0] = 1;
  {
    int i;
    for (i = 1; i <= min(arr[0], K); i++) dp[0][i] = 1 + dp[0][i - 1];
    for (; i <= K; i++) dp[0][i] = dp[0][i - 1];
  }
  for (int i = 1; i < N; i++) {
    for (int j = 0; j <= K; j++)
      dp[i][j] = mod(dp[i - 1][j] -
                     (j - arr[i] - 1 < 0 ? 0 : dp[i - 1][j - arr[i] - 1]) +
                     (!j ? 0 : dp[i][j - 1]));
  }
  cout << dp[N - 1][K] - (!K ? 0 : dp[N - 1][K - 1]) << endl;
}
