#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> arr(n);
  for (int i = 0; i < (n); ++i) cin >> arr[i];
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1));
  for (int i = 1; i <= (k); ++i) dp[0][i] = 0;
  for (int i = 0; i <= (n); ++i) dp[i][0] = 1;
  for (int i = 1; i <= (n); ++i) {
    for (int j = 1; j <= (k); ++j) {
      dp[i][j] =
          (dp[i - 1][j] % 1000000007 + dp[i][j - 1] % 1000000007) % 1000000007;
      ;
      if (j - 1 - arr[i - 1] >= 0) dp[i][j] -= dp[i - 1][j - 1 - arr[i - 1]];
    }
  }
  cout << dp[n][k] << '\n';
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
