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