#include <bits/stdc++.h>
using namespace std;
const long long int mod = (1e9) + 7;
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> arr(n, 0);
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  vector<vector<long long int>> dp(n + 1, vector<long long int>(k + 1, 0));
  dp[0][0] = 1;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 0; j <= k; j++) {
      if (j == 0) {
        dp[i][j] = 1;
        continue;
      }
      long long int ans = 0;
      if (arr[i - 1] >= j) {
        dp[i][j] += dp[i - 1][j];
      } else {
        dp[i][j] += dp[i - 1][j] - dp[i - 1][j - arr[i - 1] - 1];
      }
      dp[i][j] += dp[i][j - 1];
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][k] % mod << endl;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
